Hi there,
I am using a UserControl as a PlugIn in Navisworks 2012 (based on the BasicDockPanePlugin example). When the size of the host window is changed the UserControl does not respond.
How can I dock the UserControl to the host window or subscribe to an event that is fired when the window is resized?
Kind regards,
Gregor
ok. figured it out. for (my own) future reference:
//subscribe to the SizeChanged event of the parent of the UserControl which is of type Forms.Panel
Panel hostPanel= (Panel)this.Parent;
hostPanel.SizeChanged += new EventHandler(hostPanel_SizeChanged);
//size controls to taste when the event is raised
void hostPanel_SizeChanged(object sender, EventArgs e)
{
anyControl.Width = this.Parent.Width - 5;
}
Hi I'm trying to achieve this as well however I am getting null value on (Panel)this.Parent;
I'm trying to set this in the Load is this where you are running it from?
Cheers
I worked it out
protected override void OnVisibleChanged(EventArgs e) { base.OnVisibleChanged(e); _hostPanel = (Panel)Parent; _hostPanel.SizeChanged += (hostPanel_SizeChanged); ResizeControl(); } private void hostPanel_SizeChanged(object sender, EventArgs e) { ResizeControl(); } public void ResizeControl() { Width = _hostPanel.Width; Height = _hostPanel.Height; }