当我将其加载到面板时,DatagridView剂量显示任何数据 [英] DatagridView dosent show any data when I load it to panel

查看:70
本文介绍了当我将其加载到面板时,DatagridView剂量显示任何数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Datagridview放在UserControl内.然后按下按钮,将这个usercontol加载到主窗体的面板中,但是它显示了我数据库中的所有数据
我的代码用于按钮单击:

I put a Datagridview inside a UserControl. and I load this usercontol inside a panel in my mainform by pressing a button but it dosent show any data from my database
my code is for button click:

foreach (Control ctrl in panelMain.Controls)
            {
                ctrl.Dispose();
            }
           
            panelMain.Controls.Add(new usercontrol());

推荐答案

代码片段您提供给我们的信息可能会/可能不会显示任何数据:这完全取决于您编写的usercontrol构造函数.

由于我们看不到您是否在构造函数中进行了任何数据库访问,因此我们看不到是否存在问题.

但是,据推测,在设计时,您可能在设计器中设置了数据源值?您在构造函数中执行此操作吗?
The code fragment you have given us may / may not display any data: it is all dependant on the usercontrol constructor you have written.

Since we can''t see if you have made any database accesses in your constructor, we can''t see if there is a problem.

But, at a guess, when you designed it, you probably set a datasource value in the designer? Do you do that in your constructor?



这篇关于当我将其加载到面板时,DatagridView剂量显示任何数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆