I created a UserControl for my project and I put a DataGridView inside this control. I chose a DataSource for this DataGridView from my database.
But when I bring this UserControl to my main form and run the project, it doesn't show any data from my database.
When I directly create DataGridView inside my main form, it works.
I need开发者_JAVA技巧 to do this by using UserControl.
When you use the IDE you are just providing the template (and other configuration metadata); you must still provide the actual data-source at runtime, for example by populating an object model or DataTable and assigning that as the DataSource of either the DataGridView or (more commonly when using the IDE) the BindingSource object that the designer added.
精彩评论