|
-
Apr 3rd, 2008, 12:52 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [2005]bringing panels to the front
How do I give focus to a particular panel on a tabpage that has several panels?
Last edited by Psychlotron; Apr 3rd, 2008 at 01:06 PM.
-
Apr 3rd, 2008, 12:56 PM
#2
Re: bringing panels to the front
focus is given when you call the .focus() method of a given control. Usually you want to focus to a control that accepts input, so you would actually call the focus() method on the control that is inside the panel that you want to be focused.
However focus is not the same thing as Z-Order which is the logical order of controls stacked on the form. To bring a control on top of another (or send it behind) you want to use .BringToFront() and .SendToBack() which are methods available on any control class.
-
Apr 3rd, 2008, 01:06 PM
#3
Thread Starter
Hyperactive Member
Re: bringing panels to the front
That helped, but it still works a little funky. So, in total, I've created some buttons at runtime and added them to a panel named 'pnlDual' which is itself initially on TabPage1 of TabControl1. If pnlDual is the only panel in my TabControl, then everything works fine. At each TabControl1.SelectedIndexChanged I add pnlDual to the selected tabpage's control list.
But as soon as I add another panel (Panel1) to any TabPage at design time, suddenly I can never see pnlDual at runtime.
So I tried the pnlDual.BringToFront() procedure and that didn't work. But if I did this:
Code:
pnlDual.BringToFront()
Panel1.SendToBack()
then it works. Is this just something that I am going to have to live with, or is there a way to make the BringToFront procedure work on its own?
Thanks!
-
Apr 3rd, 2008, 01:09 PM
#4
Re: [2005]bringing panels to the front
are you sure when you added panel1 at design time, you didn't add it to pnlDual (panels can contain other panels), instead of the TabPage itself?
-
Apr 3rd, 2008, 01:13 PM
#5
Thread Starter
Hyperactive Member
Re: [2005]bringing panels to the front
Ahh, so clever. I think you got it. I'm going to work around with it for a while, thank you!
-
Apr 3rd, 2008, 01:21 PM
#6
Thread Starter
Hyperactive Member
Re: [2005]bringing panels to the front
It did work! That little problem of having one panel inside another and not knowing about it was really shaking my confidence in .net. I figured something like "BringToFront()" ought to work like the name said. Of course, it does, so long as it isn't bringing itself to the front, covered by its own "clothing".
-
Apr 3rd, 2008, 01:23 PM
#7
Re: [RESOLVED] [2005]bringing panels to the front
yeah, when dragging around controls in the IDE, you will see the icon change if releasing the mouse at that given moment means the controls container is going to change. Keep that in mind when moving controls around on forms, especially when you have a lot of container controls like it sounds you do.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|