Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » General

Post new topic   Reply to topic
How to retrieve Container of control ?
View previous topic :: View next topic  
Author Message
vb_programmer
Freshman


Joined: 03 Jan 2004
Posts: 31

PostPosted: Jan 3rd, 2004 03:00 PM    Post subject: How to retrieve Container of control ? Reply with quote

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
View user's profile Send private message Visit poster's website Yahoo Messenger ICQ Number
P.T.A.M.
Administrator


Joined: 08 Oct 2003
Posts: 752
Location: Greece

PostPosted: Jan 3rd, 2004 03:24 PM    Post subject: Reply with quote

Here you go Wink

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
View user's profile Send private message Send e-mail Visit poster's website ICQ Number
vb_programmer
Freshman


Joined: 03 Jan 2004
Posts: 31

PostPosted: Jan 3rd, 2004 10:31 PM    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website Yahoo Messenger ICQ Number
P.T.A.M.
Administrator


Joined: 08 Oct 2003
Posts: 752
Location: Greece

PostPosted: Jan 4th, 2004 05:42 PM    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website ICQ Number
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » General All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic