applying splitter resizing on tab pages
-
I have added 3 tab pages to a form. On each tab page the same user control has been added. On the control there is a left docked treeview and a right docked text boxes. I have added a splitter between these controls so that I'm able to change the size of the treeview. Once I change the size of the treeview in one tab the splitter should be located accordingly in the other tab pages as well so that I don't need to resize it. How can I achieve this?:zzz: samitha
-
I have added 3 tab pages to a form. On each tab page the same user control has been added. On the control there is a left docked treeview and a right docked text boxes. I have added a splitter between these controls so that I'm able to change the size of the treeview. Once I change the size of the treeview in one tab the splitter should be located accordingly in the other tab pages as well so that I don't need to resize it. How can I achieve this?:zzz: samitha
Hi Smitha, Problem lies in the layout of the
userControl
In your case the constituentcontrol
s of theuserControl
should be put in the following sequence: Step1.PuttreeView
control on theuserControl
, withDock
asLeft
step2.Putsplitter
control, withDock
asLeft
Step3.Put apanel
on theuserControl
, withDock
as**Fill**
Step4.put all thetextBoxes
of theuserControl
in the above mentionedpanel
. This should solve your problem. Do revert back whether you could solve the problem or not? (Note: Please delete all the constituent controls from your UserControl and start from Step1) Regards, Jay -
I have added 3 tab pages to a form. On each tab page the same user control has been added. On the control there is a left docked treeview and a right docked text boxes. I have added a splitter between these controls so that I'm able to change the size of the treeview. Once I change the size of the treeview in one tab the splitter should be located accordingly in the other tab pages as well so that I don't need to resize it. How can I achieve this?:zzz: samitha
What Jay said is partly right, but don't delete all your controls! Whatever the designer does is also manually possible. Remember that most design-time serialization is your actual source code file. You need to set the
TabIndex
of each control accordingly. So, the order that Jay was talking about is the order you should use for yourTabIndex
s for eachControl
. Then, inControls.AddRange
(the method to add controls to a parent control that you'll see in your source code), add the controls in the reverse order you did above. Internally,AddRange
iterates through the control array in reverse. You could also just useControls.Add
- in which case you add the controls in theTabStop
order - but you could potentially break the designer (behavior varies; it really likes usingAddRange
). Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] -
Hi Smitha, Problem lies in the layout of the
userControl
In your case the constituentcontrol
s of theuserControl
should be put in the following sequence: Step1.PuttreeView
control on theuserControl
, withDock
asLeft
step2.Putsplitter
control, withDock
asLeft
Step3.Put apanel
on theuserControl
, withDock
as**Fill**
Step4.put all thetextBoxes
of theuserControl
in the above mentionedpanel
. This should solve your problem. Do revert back whether you could solve the problem or not? (Note: Please delete all the constituent controls from your UserControl and start from Step1) Regards, JayJay_sh_s wrote: (Note: Please delete all the constituent controls from your UserControl and start from Step1) That's not necessary and would be a waste of time, especially if lots of code was already written. You'd have to reset all the properties and hook the event handlers back up. See my reply for how to fix this without removing all your controls and starting over with a fresh layout. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles]
-
Jay_sh_s wrote: (Note: Please delete all the constituent controls from your UserControl and start from Step1) That's not necessary and would be a waste of time, especially if lots of code was already written. You'd have to reset all the properties and hook the event handlers back up. See my reply for how to fix this without removing all your controls and starting over with a fresh layout. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles]
Dear Heath, Thanks a lot for the added informations. Though I was knowing it roughly but had never tried. Now onwards, I will do exactly what you have suggested. Regards, Jay.
-
What Jay said is partly right, but don't delete all your controls! Whatever the designer does is also manually possible. Remember that most design-time serialization is your actual source code file. You need to set the
TabIndex
of each control accordingly. So, the order that Jay was talking about is the order you should use for yourTabIndex
s for eachControl
. Then, inControls.AddRange
(the method to add controls to a parent control that you'll see in your source code), add the controls in the reverse order you did above. Internally,AddRange
iterates through the control array in reverse. You could also just useControls.Add
- in which case you add the controls in theTabStop
order - but you could potentially break the designer (behavior varies; it really likes usingAddRange
). Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles]Heath Wrote:- You could also just use Controls.Add - in which case you add the controls in the
**TabStop**
order - 1.It should beTabIndex
order...NOTTabStop
order...am I right? seems to be typing mistake on your part. 2.I just tried it, actually it is adding in reverse order, not in thetabIndex
order. like below://......................
//....................
this.treeView1.TabIndex = 0;
//..................//.................
//................
this.splitter1.TabIndex = 1;
//.................//.....................
this.panel1.TabIndex = 2;
//...................this.Controls.Add(this.panel1);
this.Controls.Add(this.splitter1);
this.Controls.Add(this.treeView1);Please clearify. Regards, Jay.
-
Heath Wrote:- You could also just use Controls.Add - in which case you add the controls in the
**TabStop**
order - 1.It should beTabIndex
order...NOTTabStop
order...am I right? seems to be typing mistake on your part. 2.I just tried it, actually it is adding in reverse order, not in thetabIndex
order. like below://......................
//....................
this.treeView1.TabIndex = 0;
//..................//.................
//................
this.splitter1.TabIndex = 1;
//.................//.....................
this.panel1.TabIndex = 2;
//...................this.Controls.Add(this.panel1);
this.Controls.Add(this.splitter1);
this.Controls.Add(this.treeView1);Please clearify. Regards, Jay.
I said that if you use
Controls.Add
you must add the controls in the order ofTabIndex
. You only reverse the order when usingControls.AddRange
. Please re-read my post for clarification. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles]