有没有一种方法可以使用 c# (Windows Forms) 从 Designer 访问自定义用户控件中的控件属性
Is there a way to access control properties within custom user control from Designer using c# (Windows Forms)
我这里有一些带有 DataGridView
的自定义用户控件,现在当我将我的用户控件实现为某种形式时,我希望能够访问设计器中的 DataGridView
属性,这可能吗?
这是我的用户控件
public partial class MyUserControlTest01 : UserControl
{
// my way to accsses DataGridView
//
public DataGridView Dtv_userControl
{
get { return myUserControl_datagridView; }
set { myUserControl_datagridView = value; }
}
public MyUserControlTest01()
{
InitializeComponent();
}
因此,当我将此用户控件实现到某个表单时,我可以从代码访问 DataGridView
属性,但我想从 Designer 中访问。
希望我的问题很清楚,
任何建议都是有帮助的。
感谢您的宝贵时间。
只需在您的 DataGridView 上添加这些注释-属性
[Browsable(true)]
[Category("*Any category you want*")]
public DataGridView Dtv_userControl
{
get { return myUserControl_datagridView; }
set { myUserControl_datagridView = value; }
}
我这里有一些带有 DataGridView
的自定义用户控件,现在当我将我的用户控件实现为某种形式时,我希望能够访问设计器中的 DataGridView
属性,这可能吗?
这是我的用户控件
public partial class MyUserControlTest01 : UserControl
{
// my way to accsses DataGridView
//
public DataGridView Dtv_userControl
{
get { return myUserControl_datagridView; }
set { myUserControl_datagridView = value; }
}
public MyUserControlTest01()
{
InitializeComponent();
}
因此,当我将此用户控件实现到某个表单时,我可以从代码访问 DataGridView
属性,但我想从 Designer 中访问。
希望我的问题很清楚, 任何建议都是有帮助的。
感谢您的宝贵时间。
只需在您的 DataGridView 上添加这些注释-属性
[Browsable(true)]
[Category("*Any category you want*")]
public DataGridView Dtv_userControl
{
get { return myUserControl_datagridView; }
set { myUserControl_datagridView = value; }
}