E
Eric
I'm a bit new to this Windows Forms thing and a bit lost on this one.
This app I'm on has a TextCell class (inheriting from something called
TableCell, which in turn inherits from Panel) with a TextBox. This
TextBox is bound to a table in a DataSet. So here's the problem: when
the app loads if I change a text field (TextBox in a TextCell with text
of say "monkey"), then move on to another, then put the edited one back
in focus, then change it (say hit the 's' key)... TextChanged then
fires twice, once for the change ("monkey" + "s"), then another time to
change it back to the previously edited but pre-re-focused value
("monkey"). So for a split second the field says "monkeys" then
immediately changes back to "monkey" and puts the cursor at the
beginning of the text. Make sense? Subsequent changes work fine, so
long as it never loses focus.
Sample:
public TextCell(...) {
this._textBox.DataBindings.Add("Text",AppStart.Instance.dsDataSubSet.Tables[this._tableName],"data");
this._textBox.TextChanged += new EventHandler(_textBox_TextChanged);
}
private void _textBox_TextChanged(object sender, EventArgs e) {
DataRow[] dr =
AppStart.Instance.dsData.Tables[0].Select(...stuff...);
if(dr.Length == 0){
...
NewRow = a new row
...
AppStart.Instance.dsData.Tables[0].Rows.Add(NewRow);
}
else{
dr[0]["data"] = this._textBox.Text;
}
this._textBox.BindingContext[AppStart.Instance.dsDataSubSet.Tables[this._tableName]].EndCurrentEdit();
}
I've seen that there may be a bug if the Text property is changed
programmatically, but that's not the case here. Ideas anyone?
Thanks,
Eric
This app I'm on has a TextCell class (inheriting from something called
TableCell, which in turn inherits from Panel) with a TextBox. This
TextBox is bound to a table in a DataSet. So here's the problem: when
the app loads if I change a text field (TextBox in a TextCell with text
of say "monkey"), then move on to another, then put the edited one back
in focus, then change it (say hit the 's' key)... TextChanged then
fires twice, once for the change ("monkey" + "s"), then another time to
change it back to the previously edited but pre-re-focused value
("monkey"). So for a split second the field says "monkeys" then
immediately changes back to "monkey" and puts the cursor at the
beginning of the text. Make sense? Subsequent changes work fine, so
long as it never loses focus.
Sample:
public TextCell(...) {
this._textBox.DataBindings.Add("Text",AppStart.Instance.dsDataSubSet.Tables[this._tableName],"data");
this._textBox.TextChanged += new EventHandler(_textBox_TextChanged);
}
private void _textBox_TextChanged(object sender, EventArgs e) {
DataRow[] dr =
AppStart.Instance.dsData.Tables[0].Select(...stuff...);
if(dr.Length == 0){
...
NewRow = a new row
...
AppStart.Instance.dsData.Tables[0].Rows.Add(NewRow);
}
else{
dr[0]["data"] = this._textBox.Text;
}
this._textBox.BindingContext[AppStart.Instance.dsDataSubSet.Tables[this._tableName]].EndCurrentEdit();
}
I've seen that there may be a bug if the Text property is changed
programmatically, but that's not the case here. Ideas anyone?
Thanks,
Eric