H
herceg
I have a problem with a custom data-bound control which inherits from
TextBox. Its code is basically
class MyBox: TextBox
{
public string MyText
{
get { return base.Text; }
set { base.Text = value; }
}
}
and the only difference between MyBox and TextBox is that MyBox has a
blue background
I put MyBox on a form which also holds a DataSet and a BindingSource.
Then I bind MyBox.MyText to a field in a DataTable. When I use it on
one record, it works fine (MyBox shows value in the field and by typing
in it I can modify the value).
But when I try navigating through the DataTable using the
BindingSource.MovePrevious and .MoveNext methods, DataRows get modified
even if I don't change anything (by typing in MyBox). I then replace
MyBox with TextBox, bind it the same way and navigation doesn't modify
rows, which is expected behavior.
What is different between the original TextBox and MyBox? Why does
MyBox modify rows?
I detect modified rows by calling GetChanges and checking the
Rows.Count property, and every time I navigate to another row, it gets
modified.
I suppose I should implement something to support data change
notifications in MyBox class, but I don't know what.
Please help!
TextBox. Its code is basically
class MyBox: TextBox
{
public string MyText
{
get { return base.Text; }
set { base.Text = value; }
}
}
and the only difference between MyBox and TextBox is that MyBox has a
blue background
I put MyBox on a form which also holds a DataSet and a BindingSource.
Then I bind MyBox.MyText to a field in a DataTable. When I use it on
one record, it works fine (MyBox shows value in the field and by typing
in it I can modify the value).
But when I try navigating through the DataTable using the
BindingSource.MovePrevious and .MoveNext methods, DataRows get modified
even if I don't change anything (by typing in MyBox). I then replace
MyBox with TextBox, bind it the same way and navigation doesn't modify
rows, which is expected behavior.
What is different between the original TextBox and MyBox? Why does
MyBox modify rows?
I detect modified rows by calling GetChanges and checking the
Rows.Count property, and every time I navigate to another row, it gets
modified.
I suppose I should implement something to support data change
notifications in MyBox class, but I don't know what.
Please help!