Custom control that adds additional control
I am designing a custom control and I need to have the control add an additional control to the form when a specific property is set to True. The best way I can describe it is like in MS Access forms when you set the record selectors property to true is adds a long button to the left side of the form and if you change it back it removes the button. The control I am designing is going to be docked at the bottom of the form and when the specific property is set to true it needs to add a control docked to the left side of the form just like Access does with its record selector control. I would make it one control but I can't have one part docked at the bottom and another part of it docked on the left side so I figure it needs to be broken up into two controls. The other catch is that the Main control which is at the bottom of the form needs to respond to the events of the control which it adds to the left side of the form.
Any Help would be greatly appriciated. :confused:
[994 byte] By [
Ron Weller] at [2007-11-11 10:16:33]

# 1 Re: Custom control that adds additional control
Try this;
make a parent invisible control that cover the whole form and put in it both two other controls, then when control1 get changed its property to true , it will comunicate with the parent control which can make what u need with the control2 as a control in it ..
I think u understand the rest .. try it .
Amahdy at 2007-11-11 17:22:49 >

# 2 Re: Custom control that adds additional control
Ok so the parent control automatically resizes to the entire form, the background would be transparent, not invisable, becaues that would make all of the other contained controls invisable as well. Now I should not make it a container so that any controls added to the form don't get added to my control, only added to the form. This sounds promising I will give it a try, thank you!
# 3 Re: Custom control that adds additional control
Yea u r right about visibility, but if u r in the case of making it transparent, u may make one only control with some part transparent in it to show the bottom bar, and the left bar when needed .. but dealing with this I think will make u overload uneeded coding and time in your project, so why not try to solve this by for example making a property called background, bydefault equal the container form backcolor ... yes u may add additional controls over this control but this will not affect any thing and the control will look like invisible in case container form backcolor , the problem if u have a background picture u need to redraw it again .. but remember the parent control will cover the whole form so no panic with this again as drawing this picture in it will look like as if it was transparent .
Hope this helps and gives u idea .
Sincerely .
Amahdy at 2007-11-11 17:25:00 >

# 4 Re: Custom control that adds additional control
None of my controls need to be transparent. So having the background transparent is fine. It does not need to be set by users. I just need a way to show the controls docked at the bottom and be able to add or remove the one docked on the left. I might even allow them to dock it on the right if they want. The main controls need to be docked at the bottom to get the effect I want. When you add my control to the form I want it to seem like it is an extension of the form. Like having an enhanced form with extra features that my control provides. I don't want it to get in the way of the forms normal use, like adding other controls which can set properties and respond to events, including those that are providrd by my control.
# 5 Re: Custom control that adds additional control
I meant some thing like this :
Dim f As Form
Set f = UserControl.ContainerHwnd
UserControl.BackColor = f.BackColor
Amahdy at 2007-11-11 17:26:53 >
