Hi,
Hemang Shah said:
Thanks for the reply Bill
Let me try to explain again as to what I want.
I have one dataset with lets say 5 tables, and they are related to each
other with relations.
I have a form, with 4 tabs.
I created a dataview on the primary table so that I can sort by first
name / last name.
The related data from the child tables are shown in the respective tabs.
I'm using bound forms with data binding.
So the fields on the form (not the tabs) is bound to the dataview.
The fields on the tabs (which are of the child table) are bound via a
dataview using its relationname.
So that whenever another records is selected on the main form, the
respective tabs are populated with the related child data.
Now, I know how to change the sort order of the main form, because its a
dataview.
What I want is to sort the data in the tabs (which is from a child table)
not by its foriegn field, but by another field like date or wotever.
Yes, I can create another dataview for this table and sort by it, but
then there would be different currency managers and the two tables won't
be in sync.
I don't know how much was I able to explain, but I can make a small
example and send it, if this was not clear enough.
Thanks for helping!
Both your parent and child controls are actually bound to a DataView, the
difference is that the parent binding is more explicit.
The framework will create a new DataView(*) for the child controls, when :
- the child controls are bound,
- the parent' row position changes.
1.
Since a new DataView is created when the parent row position changes, it
might be usefull to use a default sorting order for the created child
views, which can be done using the DefaultViewManager of the DataSet, eg:
DataSet ds = <your tables & relations>
ds.DefaultViewManager.DataViewSettings[someChildTable].Sort = ".....";
Changing this setting this will only have an effect before binding or
after the parent row position changes.
2.
You can also access the DataView from one of the child bindings, the
DataSource and DataMember used to get the CurrencyManager should be the
same as you used to bind the child controls :
DataView childDV = (DataView)((CurrencyManager)BindingContext[masterView,
"RelationToChildTable"]).List;
childDV.Sort = ".....";
Changing this settting will have an effect after binding but only until
the parent row position changes.
HTH,
Greetings
* In reality a RelatedDataView is created but it inherits from DataView.