User Control Access


I created a User Control and got it started with the following code:

// Get the User Control ID
            System.Guid panelId = UI.MainUserControl.PanelId;

            //Check if the panel is already opend, if not, open it
            bool panelVisible = Rhino.UI.Panels.IsPanelVisible(panelId);
            if (!panelVisible)

I added some public properties to the User Control and would like to access them (It’s a text field)

I tried

object test = Rhino.UI.Panels.GetPanel(panelId);

but that only returns something as an “object” through which I can’t access the properties.

How can I gain access to my custom User Control Panel’s Properties?


You could try casting it to your class type:

object panel = Rhino.UI.Panels.GetPanel(panelId);
if (null != panel)
  MyUserControl myControl = panel as MyUserControl; // use 'as' operator to cast to the desired type. If not successful it wil be null
  if (null != myControl)
    // access object as correct type