how to get usercontrol from DockingPanel?


Author
Message
JSW W.
JSW W.
Supreme Being (127 reputation)Supreme Being (127 reputation)Supreme Being (127 reputation)Supreme Being (127 reputation)Supreme Being (127 reputation)Supreme Being (127 reputation)Supreme Being (127 reputation)Supreme Being (127 reputation)Supreme Being (127 reputation)
Group: Forum Members
Posts: 127, Visits: 1
Many thanks
I will give it a try and will sure to let you know the result.

Blagovest Milanov
Blagovest Milanov
Supreme Being (148 reputation)Supreme Being (148 reputation)Supreme Being (148 reputation)Supreme Being (148 reputation)Supreme Being (148 reputation)Supreme Being (148 reputation)Supreme Being (148 reputation)Supreme Being (148 reputation)Supreme Being (148 reputation)
Group: Forum Members
Posts: 154, Visits: 15

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


JSW W.
JSW W.
Supreme Being (127 reputation)Supreme Being (127 reputation)Supreme Being (127 reputation)Supreme Being (127 reputation)Supreme Being (127 reputation)Supreme Being (127 reputation)Supreme Being (127 reputation)Supreme Being (127 reputation)Supreme Being (127 reputation)
Group: Forum Members
Posts: 127, Visits: 1
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?


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search