开发者

DatagridView doesn't show any data when I run my project

开发者 https://www.devze.com 2023-02-10 09:06 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号