Two TextBox - same data field

  • Thread starter Thread starter ftrl
  • Start date Start date
F

ftrl

Hello,

On a Winform, a dataset and a binding source.
I would like to have 2 TextBox to the same column.
I bind the Text property to the column like this (extract from
Form1.Designer.cs) :

textBox1.DataBindings.Add(new System.Windows.Forms.Binding("Text",
this.bindingSource1, "Column1", true));
textBox2.DataBindings.Add(new System.Windows.Forms.Binding("Text",
this.bindingSource1, "Column1", true));

If I type something in the first TextBox, when I tab out, I would like
the second TextBox filled by the text (wich now is in the DataRow). It
is not the case. The second TextBox stays blank.

More generally, when I change a column value in the active DataRow, I
would like the columns's bound control to be refreshed.

Any suggestion ?
(sorry for my english).

Jean
 
Is there a need to bind the second control? Will the user make edits
there? If not, try using the TextChanged event of textBox1 to set the
value of textBox2.
Private Sub textBox1_TextChanged.....
textBox2.Text=textBox1.Text
End Sub.....

I use this method to update link labels for web addresses.

The bound controls aren't updated until you call the update method of
the tableadapter. You could call the update method on the LostFocus
event of textBox1 if you are ready to update the underlying data at
that point.

Dwight
 
Back
Top