I am working on a form with a grid or listview which will show data from a related table as a lookup and I would like to show a descritive fields instead of the Foreing Key field value, how can I do this?
In the picture attached, the FK_Appliances in the Grid or Appliance in the List View are the ones I want to show the descriptive field instead of the FK value.
Also, since I am learning SF, I found that the creation of a ListView is a bit difficult than using a GridView for read only data, is there a way to show the grid with empty columns like in the ListView in order to cover the gray area of the grid?
Thanks!
I don't know if you knew this, but you can create a parameter and provide the value all in one statement:
It is a handy little trick
Hi Trent,
Thanks again, for checking the code. And please do not assume what I would know for know, since I am learning VB.NET, SF, SQL2005 and more at the same time, so there are many things I don't know or fully understand yet.
I replaced the two command lines with the single one and it is much cleaner. I also kind a like the Scalar methods now that I know they exist
In a Browser Dialog, I need also to show a descriptive field name and tried using the same code in the ServiceCallsBO1_BrowseDialog_RowPopulating, but it generates this error:
Source : ATR System
Stack Trace: at ATR_System.frmServiceCalls.ServiceCallsBO1_BrowseDialog_RowPopulating(RowPopulatingEventArgs e) in E:\Visual Studio 2005\StrataFrame Projects\ATR Systems\ATR System with not security\ATR System\Forms\frmServiceCalls.vb:line 235 at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogwindow.CreateListViewItem() at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogwindow.LoadBrowseResults() at MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogwindow.ExecuteSearch() at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e) at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e) at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e) at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ToolStrip.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m) at System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Here is the code in ServiceCallsBO1_BrowseDialog_RowPopulating:
With CType(e.BusinessObject, ATR_BO_Library.ServiceCallsAppliancesBO) Dim loBO As New ATR_BO_Library.AppliancesBO e.Values(1).DisplayValue = loBO.GetApplianceName(.FK_Appliances) End With
With CType(e.BusinessObject, ATR_BO_Library.ServiceCallsAppliancesBO)
Dim loBO As New ATR_BO_Library.AppliancesBO
e.Values(1).DisplayValue = loBO.GetApplianceName(.FK_Appliances)
End With
What is wrong with this approach in the Browser Dialog?
Here is a tip...it isn't the Browse Dialog
Sorry about that, it was a copy/paste problem, here is the code:
e.Values(1).DisplayValue = loAppliancesBO.GetApplianceName(.FK_Appliances)
loAppliancesBO.Dispose()
After a second thought, I decided to try Tim's suggestion to create a Custom Property and after reading Tim's great sample and with the SF help file, I could not believe how easy it was to have 2 Custom Field Properties to handle this situation and not have to add a single line of code at the form level, which keep the things simple.
For the sake of new SF users, here is the code for one of my Custom Field Properties:
<Browsable(
BusinessFieldDisplayInEditor(), _
Description(
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
loBusinessObject.FillByPrimaryKey(
loBusinessObject.Dispose()
Once again, big thanks to Tim and Trent for the lecture on how to accomplish this task.