Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > how do i do this?
 

how do i do this?

row

field1    field2    field3

field1-guid

field2-guid

field3-guid

i need to display another value from another table using the guids.

something similar to combobox usage, with displayvalue and valuemember.

 example of my grid display as now:

 

  eb72d29c-045a-4650-83dd-cefb991ebe1c ca101 1/1/2001 CT10 Cheque 1.00 ZAR   FORWARDER m555 e06e6dd2-c886-4a8f-8d85-2508dc2c13e5 49f1b0ea-7ddb-443a-9253-5adc03acb726 0a7d2981-a4e1-4a61-9c75-14ad1515b6d2

 

the first column is my pk, so it will be hidden. the other guid displayed are all fk in a table called bill and should display amount.

 

 

hrubesh  Wednesday, October 04, 2006 10:04 AM

Hi,

One easy way to do this is to use a JOIN query to fill your table. If you won't be nedding to edit the GUIDs, then instead of specifying them in your SELECT statement on the TableAdapter, join to the FK table and select the actual amount.

If for some reason you absolutely must retrieve those GUIDs, then assuming you have both tables in your DataSetand a relation between them, you could handle the CellFormatting event on your DataGridView, and in there do a lookup in the second table based. This could be done by either using the Find method on a BindingSource for your second table, or through the GetParentRow() method of the DataRow currently being rendered in the grid.

Hope this helps.

Luc

Luc Morin  Wednesday, October 04, 2006 11:13 AM

Hi,

One easy way to do this is to use a JOIN query to fill your table. If you won't be nedding to edit the GUIDs, then instead of specifying them in your SELECT statement on the TableAdapter, join to the FK table and select the actual amount.

If for some reason you absolutely must retrieve those GUIDs, then assuming you have both tables in your DataSetand a relation between them, you could handle the CellFormatting event on your DataGridView, and in there do a lookup in the second table based. This could be done by either using the Find method on a BindingSource for your second table, or through the GetParentRow() method of the DataRow currently being rendered in the grid.

Hope this helps.

Luc

Luc Morin  Wednesday, October 04, 2006 11:13 AM
Yep i prefer going by setting the cellformatting but i am getting an exception by doing tht.
hrubesh  Wednesday, October 04, 2006 11:59 AM

hrubesh wrote:
Yep i prefer going by setting the cellformatting but i am getting an exception by doing tht.

Hi,

It would really help if you could provide detais of the exception.

Luc

Luc Morin  Wednesday, October 04, 2006 12:22 PM

Yep it works

Private Sub DataGridView1_CellFormatting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles DataGridView1.CellFormatting

Try

If not IsNothing(tb.Rows.Find(Me.DataGridView1.Columns(e.ColumnIndex).Name.Trim())) Then

e.Value = p.myInvoices_0.myInv.FindByBillID(e.Value).AmountFC.ToString

e.FormattingApplied = True

End If

Catch ex As Exception

End Try

End Sub

Thanks

hrubesh  Thursday, October 05, 2006 4:31 AM

You can use google to search for other answers

Custom Search

More Threads

• How do I cancel a web thread?
• Report Viewer Control ?
• Selected index change problem
• Combo box in data grid
• Listview-like functionality from a DataGridView?
• DataGrid Formatting when bound to ArrayList?
• Minimizing windows in client/server app?
• DataGridView
• Right way to use a DataGridView Bound to Data
• Getting Gridview to open up in new page