Profile Picture

how to get usercontrol from DockingPanel?

Posted By JSW W. 14 Years Ago
Author
Message
JSW W.
Posted 14 Years Ago
View Quick Profile
Supreme Being

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
Last Active: 12 Years Ago
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?



bob milanov
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)

Group: Forum Members
Last Active: 6 Months Ago
Posts: 153, Visits: 11

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.
Posted 14 Years Ago
View Quick Profile
Supreme Being

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
Last Active: 12 Years Ago
Posts: 127, Visits: 1
Many thanks
I will give it a try and will sure to let you know the result.




Similar Topics


Reading This Topic