从另一种形式引用datagridview码头属性 [英] Referensing a datagridview dock property from another form
本文介绍了从另一种形式引用datagridview码头属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我需要访问赢表格datagridview的
另一个码头的属性
形式. Hoiw这可能吗?
Hi all,
I need to access a win forms datagridview''s
dock properties from another
form. Hoiw is this possible?
Please any help would be appriciated.
推荐答案
在您的表单中,make属性会将特定的网格或属性暴露给其他对象.
例如,在具有dataGridView的表单中,您将具有:
In your form make property which will expose particular grid or property to other objects.
For instance in your form with dataGridView you''ll have:
public DataGridView MyDataGridView
{
get
{
return this.myDataGridView;
}
}
public DockStyle MyGridsDockProperty
{
get
{
return this.myDataGridView.Dock;
}
set
{
this.myDataGridView.Dock = value;
}
}
//etc.
其他形式将使用以下形式:
Other form will use that:
public partial class MyOtherForm:Form
{
private MyFormWithGrid _myFormWithGrid = null;
///CTOR
public MyOtherForm(MyFormWithGrid myFormWithGrid)
{
InitializeComponnent();
_myFormWithGrid = myFormWithGrid;
}
private void MyMethodToDealWithAnoterFormsProperties()
{
myFormWithGrid.MyGridsDockProperty = DockStyle.None;
}
//etc.
}
这是非常简单的Windows Forms基础,请尝试使用一些很棒的教程或书籍
This is pretty straightforward Windows Forms basics, try using some of great tutorials or books available on internet.
这篇关于从另一种形式引用datagridview码头属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文