Reserving an area of client form

G

Guest

I've created a menu control which is derived from UserControl. This control docks at the top of the form and even checks to make sure that it docks above any other items on the form. The control is 23 pixels high so a control on the form which may have been at location (0,0) before end up getting its location changed to (0,23). Is there a way for my control to reserve or take control of the top 23 pixels of the form? Ideally, I'd like for the other controls to maintain their perception of their coordinates so that the control that used to be at (0,0) still shows a location of (0,0) when inspected. Is this possible

The problem that I have is that if I go back to the moved control and change its location back to (0,0) then my menu won't dock at the top anymore (now it docks next to the control)

To make my control dock at the top of the form I use this code in the constructor
this.Dock = DockStyle.Top

and I use this code in the paint event
if (this.Parent.Controls.GetChildIndex(this) != 1)

this.Parent.Controls.SetChildIndex (this,1)


Any help would be appreciated. Thanks.
 
G

Guest

Reposting to a broader group

----- Rhy Mednick wrote: ----

I've created a menu control which is derived from UserControl. This control docks at the top of the form and even checks to make sure that it docks above any other items on the form. The control is 23 pixels high so a control on the form which may have been at location (0,0) before end up getting its location changed to (0,23). Is there a way for my control to reserve or take control of the top 23 pixels of the form? Ideally, I'd like for the other controls to maintain their perception of their coordinates so that the control that used to be at (0,0) still shows a location of (0,0) when inspected. Is this possible

The problem that I have is that if I go back to the moved control and change its location back to (0,0) then my menu won't dock at the top anymore (now it docks next to the control)

To make my control dock at the top of the form I use this code in the constructor
this.Dock = DockStyle.Top

and I use this code in the paint event
if (this.Parent.Controls.GetChildIndex(this) != 1)

this.Parent.Controls.SetChildIndex (this,1)


Any help would be appreciated. Thanks.
 

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

Top