Suppose I have an activex control on a form, I want to write code in some event of the control which will get and modify the properties of the container form. (Left, Right, Height, Width, etc)
Any solutions ?
Printable View
Suppose I have an activex control on a form, I want to write code in some event of the control which will get and modify the properties of the container form. (Left, Right, Height, Width, etc)
Any solutions ?
I'm not sure I fully understand what you mean... but this should work if I understand correctly. When you use the "Me" object in VB it refers to the form that is using it.
VB Code:
Sub Command1_Click Me.Caption = "The button has been clicked" 'Effect is WhateverYourFormNameIs.Caption = "..." End Sub
Is that what you wanted?
You use the Parent property
VB Code:
Private Sub UserControl_Click() Parent.Width = 300 End Sub
Yes, Arc is also right... but that code would be inside the code of your own UserControl. If you were using an intrinsic VB control then my code would be in your form.
Now, Arc... I have a question. How can I trap a parent form's event? i.e. something like Sub Parent_Click() though that itself doesn't work.
AS far as i know there is no built in function to do what you ask.
I imagine you would have to do some subclassing. Which i know nothing about :eek:
OK thanks, I'll either try subclassing or forget about it (I don't actually HAVE to do it)
Thanks Arc, I got it.
Just a little "survey..." by saying "Thanks Arc I got it" do you mean that you needed to use the Parent object and not the Me object?
I knew about the Me object. I required the Parent object to modify the form through an activex control. If you still didn't understand, download the two attachments from...
http://www.vbforums.com/showthread.php?postid=911932
I have used the Parent object, atleast more than 25 times.
What about using..UserControl.Extender.Parent????
UserControl.Extender gives you the properties assigned by the form to your control.
Suppose if you give the statement...
Then if the name is UserControl1 then MsgBox will say UserControl1.Code:MsgBox UserControl.Extender.Name
Extender can be used to assign properties. Suppose you want the control to be always aligned to the bottom (like status bar control), give...
Code:UserControl.Extender.Align = vbAlignBottom
Thanks 007Shahid, I know how to use all these objects and I just wanted to know which one YOU wanted. So you wanted to modify a container from a UserControl, not modify a container form on an intrinsic control's event.
by the way 007Shahid: my favorite way to post Visual Basic code is to use the [ VBCODE ] and [ /VBCODE] vB tags.
VB Code:
'This will be green Sub MySub (argument As argumentType) Me.Caption = "This is all syntax-highlighted." End Sub
VB Code:
'I hope this comes in green
Congratulations you did it! :D