从另一种形式更改网格视图数据源 [英] change grid view data source from another form

查看:71
本文介绍了从另一种形式更改网格视图数据源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两种形式(frmMain和frmSearch)

frmMain具有DataGrid和按钮控件,该按钮显示frmSearch来搜索并返回数据表,而frmMain仍处于打开状态.

当frmSearch返回带有搜索结果的数据表时,我想用此数据表填充,因此我编写此代码

I''ve two forms (frmMain and frmSearch)

frmMain have DataGrid and button controls, the button showing frmSearch to search and return datatable, and frmMain is still open.

when frmSearch returns datatable with search result i want fill with this datatable so i write this code

using (frmMain MainForm = new frmMain()
            {
                MainForm.ShowDialog();
                gvExams.DataSource = myDataTable;
            }



因此该表单实例化了一个新表单,而DataGrid没有任何内容.

我想将DataGrid控件转换为静态控件(我不能).或帮助我...



so the form instantiated a new form and DataGrid have nothing.

i want convert my DataGrid Control to a static Control (i can''t). or Help Me...

推荐答案

看看这篇文章( [
Have a look at this article("Passing Data Between Forms"[^]) in CodeProject. This will help you out.

Good luck,
OI


这篇关于从另一种形式更改网格视图数据源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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