Hi.
When binding to the Count property of a DataView, the bound control is not updated when applying a rowfilter to the DataView.
Sample code:
dt = new DataTable();
dt.Columns.Add("Val",typeof(int));
DataRow row;
row = dt.NewRow();
row["Val"]=1;
dt.Rows.Add(row);
row = dt.NewRow();
row["Val"]=2;
dt.Rows.Add(row);
row = dt.NewRow();
row["Val"]=2;
dt.Rows.Add(row);
textBox1.DataBindings.Add("Text",dt.DefaultView.Count,"");
****** the TextBox shows "3"
dt.DefaultView.RowFilter="Val=1";
****** the TextBox STILL shows "3"
Is this a bug or am I doing something wrong?
Surely I can do this without databinding, but I'm not looking for alternative solutions!
Jorgen,
My understanding is:
DataView does not have a CountChanged event, for the data bound TextBox to
update itself when DataView.Count property changes, the PropertyManager
listens for the DataView.CountChanged event, and update the TextBox
appropriately, well seeing as there is no CountChanged event, nothing
happens...
The above is assuming you bound to the Count property, not the value of
Count itself...
textBox1.DataBindings.Add("Text",dt.DefaultView,"Count");
> textBox1.DataBindings.Add("Text",dt.DefaultView.Count,"");
Also you are binding to a value type, it will be boxed, for ever breaking
the tie to the DataView itself...
Hope this helps
Jay
> Hi.
>
[quoted text clipped - 29 lines]
>
> Surely I can do this without databinding, but I'm not looking for alternative solutions!