DataViews DataTables and DataGridViews and indexing
-
Ok i have a DataTable containing a number of rows. I have two DataViews from this dataTable, one shows all the rows with a few hidden columns including a descriptionField, sorted by a date field. The second shows any rows that have a descriptionFeild that contains data only. The reason behind this is i'm producing a printable form that shows additional information if there is any on a seperate page to the rest of the data. Is there any easy way that i can get the index from one view to feedback into the dataset so it can be displayed by the second view. e.g.
data set:
date code time description
21/11/08 DOC 00:12 document detailing house sale
22/11/08 LTO 00:06
22/11/08 LTI 00:06 responce to house sale document recieveddata view 1:
date code time
21/11/08 DOC 00:12
22/11/08 LTO 00:06
22/11/08 LTI 00:06data view 2:
description
document detailing house sale
responce to house sale document recievedwhat i need is data view 2 to either have a column with the index from its row in data view 1, or any other way of getting that index. Hope i have explained this well enough, googling for other people with the same problem showed lots of badly written and confusing examples of the same problem and no useful answers.
-
Ok i have a DataTable containing a number of rows. I have two DataViews from this dataTable, one shows all the rows with a few hidden columns including a descriptionField, sorted by a date field. The second shows any rows that have a descriptionFeild that contains data only. The reason behind this is i'm producing a printable form that shows additional information if there is any on a seperate page to the rest of the data. Is there any easy way that i can get the index from one view to feedback into the dataset so it can be displayed by the second view. e.g.
data set:
date code time description
21/11/08 DOC 00:12 document detailing house sale
22/11/08 LTO 00:06
22/11/08 LTI 00:06 responce to house sale document recieveddata view 1:
date code time
21/11/08 DOC 00:12
22/11/08 LTO 00:06
22/11/08 LTI 00:06data view 2:
description
document detailing house sale
responce to house sale document recievedwhat i need is data view 2 to either have a column with the index from its row in data view 1, or any other way of getting that index. Hope i have explained this well enough, googling for other people with the same problem showed lots of badly written and confusing examples of the same problem and no useful answers.
It looks like the CurrencyManager and binding objects are what you're looking for: http://en.csharp-online.net/DataViews_and_Data_Binding%E2%80%94CurrencyManager_and_BindingContext[^] http://msdn.microsoft.com/en-us/library/system.windows.forms.currencymanager.aspx[^] These will ensure that if the two views are bound to the data through the same binding contect and currency manager, that a selection against one view will cause the same selections on the other.
modified on Monday, December 8, 2008 12:05 PM