| View previous topic :: View next topic |
| Author |
Message |
vb_programmer Freshman
Joined: 03 Jan 2004 Posts: 31
|
Posted: Jan 3rd, 2004 03:00 PM Post subject: How to retrieve Container of control ? |
|
|
Hello to All Forum Members ;
Currently I'm working on an ActiveX component and in that , I need to find out the Container of the other controls placed on the form (on which our ActiveX will be droped).
I checked MSDN and ensured that Container is a property which can be read. But I'm not getting how to retrieve the value of this property.
I tried with ...
Dim Ctrl as Control
For Each Ctrl In Form1.Controls
If Ctrl.Container = Frame1 Then
Ctrl.Enabled = False
End If
Next
This is not working and giving me error as "Wrong number of Arguments or invalid Property Assignment" ...
Actually when I saw the MSDN example code ... there they have written as ...
Set Button1.Container = Frame1
Hence I equated obj.Container with Frame1 directly (the name of control directly) in If Condition ... Is it ok or the mistake is there itself ?
Where is the mistake ? How to retrieve this Container Property ? Please help me in this ...
Waiting for your valuable reply ... _________________ ----- vb_programmer ------
iNova Creations : Software Development Company !
(www.inovacreations.com)
RutuOnline.com : A Programmer's Resource Center !
(www.rutuonline.filetap.com) |
|
| Back to top |
|
P.T.A.M. Administrator

Joined: 08 Oct 2003 Posts: 752 Location: Greece
|
Posted: Jan 3rd, 2004 03:24 PM Post subject: |
|
|
Here you go
| Code: | Private Sub UserControl_Click()
MsgBox UserControl.Extender.Container.Name
End Sub |
_________________ No one is completely useless. They can at least be an example of what to avoid. |
|
| Back to top |
|
vb_programmer Freshman
Joined: 03 Jan 2004 Posts: 31
|
Posted: Jan 3rd, 2004 10:31 PM Post subject: |
|
|
Thanks for your reply ...
Actually , I don't want to retrieve the Container of UserControl. What I'm looking for is ... if there is a TextBox (.Name = "Text1") in a Frame (.Name = "Frame1") then , how to retrieve this Frame1 name as a container of Text1 ?
Meaning , on any form , how to crowl through all the controls and see whether that control is placed directly on the form or it's in a container ; and if it's in a container , then what's the name of that container. That's what I'm looking for ... Any help in this direction please ... _________________ ----- vb_programmer ------
iNova Creations : Software Development Company !
(www.inovacreations.com)
RutuOnline.com : A Programmer's Resource Center !
(www.rutuonline.filetap.com) |
|
| Back to top |
|
P.T.A.M. Administrator

Joined: 08 Oct 2003 Posts: 752 Location: Greece
|
Posted: Jan 4th, 2004 05:42 PM Post subject: |
|
|
Oh, sorry... Maybe something like this?
| Code: | Private Sub Form_Load()
Dim Ctl As Control
For Each Ctl In Me.Controls
If Ctl.Container.Name = Me.Name Then
Debug.Print Ctl.Name
End If
Next
End Sub |
This will show you all the controls on the form that have the form as a container. If you remove the If statement then you get the names of all the controls on a form no matter what the container is... Maybe if you compare the 2 results you can see where each control is? Does this make any sence? _________________ No one is completely useless. They can at least be an example of what to avoid. |
|
| Back to top |
|
|