Nevron Forum

how to get usercontrol from DockingPanel?

https://www.nevron.com/Forum/Topic3793.aspx

By JSW W. - Tuesday, July 6, 2010

Dim t_panel As NDockingPanel
t_panel = New NDockingPanel
t_panel.Key = "ABC"
t_panel.Controls.Add(userControl)


When the time come, How can I access to userControl and panel ABC?

By Blagovest Milanov 1 - Wednesday, July 7, 2010

Hi,

You just have to get the parent and cast it to NDockingPanel - for example:

 public class MyUserControl : UserControl
 {
  public MyUserControl()
  {

  }

  public string ParentKey
  {
   get
   {
    NDockingPanel dockPanel = this.Parent as NDockingPanel;

    if (dockPanel == null)
     return string.Empty;

    return dockPanel.Key;
   }
  }
 }

 public partial class Form1 : Form
 {
  public Form1()
  {
   InitializeComponent();
  }

  private void Form1_Load(object sender, EventArgs e)
  {
   NDockingPanel t_panel = new NDockingPanel();
   t_panel.Key = "ABC";

   MyUserControl control = new MyUserControl();
   t_panel.Controls.Add(control);

   Debug.WriteLine(control.ParentKey);
  }
 }

Best regards,
Bob

By JSW W. - Saturday, July 10, 2010

Many thanks
I will give it a try and will sure to let you know the result.