Binding Textboxes and a datagrid to a DataTable Question?

N

nate axtell

After binding a DataGrid and a few TextBoxes to the same DataTable in VB
..NET I successfully see the TextBoxes update when I change the selection in
the DataGrid. I put DataGrid1.Invalidate() in the TextBox1.Leave event to
show modifications made in the TextBox in the DataGrid. And that works too.
My problem is when I programmatically call TextBox1.Text = "abc" then call
DataGrid1.Invalidate() the DataGrid row is not updated with the correct
value from the TextBox. It is not updated at all. If I then click on a
different row to change the selection, THEN the row is updated with the
correct value that was set in the TextBox programmatically.
Does anyone have a clue why the DataGrid doesn't get the correct value from
the DataTable until after I change the selected row? Even hiding the window
and expanding it again to manually force a redraw to occur doesn't work. So
I don't think it is that Invalidate on the grid is the problem.
A work around I came up with is the following:
TextBox1.Text = "abc"
 
N

nate axtell

The workaround is:
TextBox1.Focus()
TextBox1.Text = "abc"
OtherControl.Focus() '-- calls TextBox1.Leave event which then calls
datagrid1.invalidate
 
C

Cor Ligthert

Nate,

The behaviour from the datagrid is that it changes the data in the
underlaying datasource after a rowchange or a
currencymanager.endcurrentedit. (The UI and DataTable are two different
classes). The UI does not know much from the data while the Datatable does
not know much from the UI.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top