Simple Windows Control Question

  • Thread starter Thread starter David Gacek
  • Start date Start date
D

David Gacek

I'm just wondering how can i get the properties of the container that the
control resides on in vb6 is was quite simple.

I want to get the forms width and heigth

thanks
 
The control has a Parent. There will be a chain of parent objects going
right back to the form so you can follow the chain back and get the
top-level containers propeties.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
To get the Form width and height:
From a sub within the form itself:
Me.Width, Me.Height

From outside the form:
(where frm is an instance of the form)
frm.Width, frm.Height

From outside the form:
(where ctl is an instance of the control)
ctl.parent.Width, ctl.parent.Height 'get the parent of the control
ctl.TopLevelControl.Width, ctl.TopLevelColntrol.Height

Haven't tried the following but it might work:
ctl.Container.Width, ctl.Container.Height
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top