Newbie: Simple Databinding in WinForms
Posted on 2007-07-19
I have a small WinForms application that contains
- a DataGridView,
- a BindingNavigator,
- a BindingSource and
- a Textbox
The DataGridView shows commodities coming from a database and the BindingNavigator helps the user scrolling through the rows of commodities. DataGridView and BindingNavigator are connected to the same BindingSource. Everything works as expected.
However: I want the TextBox to show a certain value (i.e. the commodity's name) of the currently focused row in the DataGridView.
Thus I set a databinding in the Forms Load()-event like this:
TextBox.DataBindings.Add("Text", commodityDataSource, "CommodityName");
When I start the application, the TextBox shows data from the first DataGridView row as expected.
But here is my problem: When I select another row in the DataGridView via Mouse or via Navigator the content of the TextBox is NOT updated.
What am I missing? Thanks for any help!