我可以在C#窗口应用程序中创建DataGridView的get或set属性 [英] can i create get or set property of DataGridView in C # Window Application
本文介绍了我可以在C#窗口应用程序中创建DataGridView的get或set属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的用户控件中添加 DataGridView .所以我想创建 get 或 set 方法用于 DataGridView .
例如,如果我在用户控件中添加一个文本框,那么如果我想设置或获取文本框的属性,那么我要编写以下代码.在这里 EmployeeFirstNametxt 是文本框名称
因此,如果可能对于DataGridView,那么请告诉......
i want to Add DataGridView in my User Control .so i want to create get or set method for DataGridView .
for Example if i add one text box in my user Control then if i want set or get property of text box so i write following code.here EmployeeFirstNametxt is text box name
so if possible for DataGridView then tell which way...
public string EmployeeFirstName
{
get
{
return EmployeeFirstNametxt.Text;
}
set
{
EmployeeFirstNametxt.Text = value;
}
}
推荐答案
您要公开哪些DataGridView属性?
您将以与EmployeeFirstNametxt.Text属性相同的方式公开它们,
例如公开DataGridViews DataSource属性;
What DataGridView properties are you wanting to expose?
You would expose them in the same way you did the EmployeeFirstNametxt.Text property,
for example to expose the DataGridViews DataSource property;
public object DataGridViewDataSource
{
get { return dgv.DataSource; }
set { dgv.DataSource = value; }
}
这篇关于我可以在C#窗口应用程序中创建DataGridView的get或set属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文