How can I force a textBox to push back changed data to its DataSource by code ?

  • Thread starter Thread starter AlanChong
  • Start date Start date
A

AlanChong

Guest
Hello. My DataTable has a lot of columns and one to any number of rows. Some of the columns are placed on a DataGridView. The rest of them are represented by textBoxes. I provide a dialog to let uses change any column to uppercase.

Let say table1 has 5 rows, It's on the first row. textBox1.Text = "". Foucs is on textBox1. The user type "abc" on textBox1.

The user hits a button to bring up a dialog to do the uppercase()

After the user hit "confirm" button, columns related to textBox1 are changed to uppercase. But textBox1.Text still show "abc" until the user uses the mouse to click on the second row and click on the first row again do textBox1.Text become "ABC"

I tried to cope with the problem by calling textBox20.Focus(), SendKeys.Send("{TAB}") to move focus from textBox1 trying to force the updating. These do move focus from textBox1. But its DataSource still doesn't get updated . Clicking another textBox forces textBox1 to send Changed text to its DataSource. Using code to move focus doesn't have the same effect. And textBoxes do not have EndEdit() as DataGridViews do. Finally I resorted to bindingSouce1.ResetBindings(false). It worked. I don't like to call ResetBindings(false) too often because it focus DataGridView to move its current cell to the first column.

Are there other methods I can force a textBox to update its changed text to its DataSource by code ? Thanks.

Continue reading...
 
Back
Top