Search code examples
c#winformsuser-controls

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?

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.

Hope my question is clear, any suggestion is helpful.

Thank you for your time.


Solution

  • Just add these annotations over your DataGridView-Property

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