troubleshooting Question

Newbie: Simple Databinding in WinForms

Avatar of softwarea
softwarea asked on
.NET ProgrammingEditors IDEs
5 Comments1 Solution986 ViewsLast Modified:
Hi experts,

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!
Ingmar
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros