简体   繁体   English

有没有一种方法可以使用C#(Windows Forms)从Designer中访问自定义用户控件中的控件属性。

[英]Is there a way to access control properties within custom user control from Designer using c# (Windows Forms)

I have here some custom user control with DataGridView in it, now when i Implement my user control to some form I want to be able to access DataGridView properties within designer, is this possible? 我这里有一些带有DataGridView自定义用户控件,现在当我以某种形式实现我的用户控件时,我希望能够在设计器中访问DataGridView属性,这可能吗?

This is my user control 这是我的用户控件

   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();

        }

So when i implement this user control to some Form, I can access DataGridView properties from code, but i want to do it from Designer. 因此,当我将此用户控件实现为某种Form时,我可以从代码访问DataGridView属性,但是我想从Designer中进行操作。

Hope my question is clear, any suggestion is helpful. 希望我的问题清楚,任何建议都是有帮助的。

Thank you for your time. 感谢您的时间。

Just add these annotations over your DataGridView-Property 只需在您的DataGridView-Property上添加这些注释

[Browsable(true)]
[Category("*Any category you want*")]
public DataGridView Dtv_userControl
{
   get { return myUserControl_datagridView; }
   set { myUserControl_datagridView = value; }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM