Home All Groups Group Topic Archive Search About

Control Container Property - Why Use It?

Author
7 Mar 2009 1:11 PM
David
I don't see the benefit or really purpose of the Container property.

For example:

         '--------------------------------
         'Use Placeholder to hold ComboBox
         '--------------------------------
         'Place cboText on tbrPlaceholder
         Set btnX = .Buttons.Add(, "phcombo", , tbrPlaceholder)
         '-------------------------------------
         'Associate any tbrPlaceholder controls with the Toolbar
         '-------------------------------------
         Set cboText.Container = Toolbar1
         Toolbar1.Buttons("phcombo").Width = cboText.Width

My understanding this identifies Toolbar1 as being the container for the
combobox.

So what?
--With or without the combobox functions as it should.
--The combobox doesn't show up under object browser Toolbar1

Anyone have an explanation why it should be used?

Thanks
David

Author
7 Mar 2009 2:06 PM
DanS
"David" <dw85745***@earthlink.net> wrote in news:eEox$YynJHA.4872
@TK2MSFTNGP04.phx.gbl:

Show quoteHide quote
> I don't see the benefit or really purpose of the Container property.
>
> For example:
>
>          '--------------------------------
>          'Use Placeholder to hold ComboBox
>          '--------------------------------
>          'Place cboText on tbrPlaceholder
>          Set btnX = .Buttons.Add(, "phcombo", , tbrPlaceholder)
>          '-------------------------------------
>          'Associate any tbrPlaceholder controls with the Toolbar
>          '-------------------------------------
>          Set cboText.Container = Toolbar1
>          Toolbar1.Buttons("phcombo").Width = cboText.Width
>
> My understanding this identifies Toolbar1 as being the container for
the
> combobox.
>
>  So what?
> --With or without the combobox functions as it should.
> --The combobox doesn't show up under object browser Toolbar1
>
> Anyone have an explanation why it should be used?

I've always used the SetParent API.

For instance, maybe you would want to provide sub-item editing on a VB
listview in report mode. You *could* do this by setting the Parent of a
TextBox to be the listview (using the .Container property of the textbox
doesn't work with a LV, but SetParent does). Set the textbox not visible,
and when a subitem is clicked/dbl-clicked, you can then use
GetSubItemRect to set the location and size of the textbox, then make it
visible.
Author
7 Mar 2009 4:38 PM
David
DanS thanks for response.

So it appears you use SetParent in lieu of Container.
So back to base question -- what good is Container?

Show quoteHide quote
"DanS" <t.h.i.s.n.t.h.a.t@r.o.a.d.r.u.n.n.e.r.c.o.m> wrote in message
news:Xns9BC75CBEAD57Bthisnthatroadrunnern@85.214.105.209...
> "David" <dw85745***@earthlink.net> wrote in news:eEox$YynJHA.4872
> @TK2MSFTNGP04.phx.gbl:
>
>> I don't see the benefit or really purpose of the Container property.
>>
>> For example:
>>
>>          '--------------------------------
>>          'Use Placeholder to hold ComboBox
>>          '--------------------------------
>>          'Place cboText on tbrPlaceholder
>>          Set btnX = .Buttons.Add(, "phcombo", , tbrPlaceholder)
>>          '-------------------------------------
>>          'Associate any tbrPlaceholder controls with the Toolbar
>>          '-------------------------------------
>>          Set cboText.Container = Toolbar1
>>          Toolbar1.Buttons("phcombo").Width = cboText.Width
>>
>> My understanding this identifies Toolbar1 as being the container for
> the
>> combobox.
>>
>>  So what?
>> --With or without the combobox functions as it should.
>> --The combobox doesn't show up under object browser Toolbar1
>>
>> Anyone have an explanation why it should be used?
>
> I've always used the SetParent API.
>
> For instance, maybe you would want to provide sub-item editing on a VB
> listview in report mode. You *could* do this by setting the Parent of a
> TextBox to be the listview (using the .Container property of the textbox
> doesn't work with a LV, but SetParent does). Set the textbox not visible,
> and when a subitem is clicked/dbl-clicked, you can then use
> GetSubItemRect to set the location and size of the textbox, then make it
> visible.
Author
7 Mar 2009 6:33 PM
Larry Serflaten
"David" <dw85745***@earthlink.net> wrote
> I don't see the benefit or really purpose of the Container property.

Add two Frame controls and place a Checkbox on one of the frames.
Paste in the code below and run the program. Click the Checkbox
a few times....

LFS

Private Sub Check1_Click()
  If Check1 Then
    Set Check1.Container = Frame1
  Else
    Set Check1.Container = Frame2
  End If
End Sub
Author
7 Mar 2009 10:28 PM
David
Thanks Mr. Serflaten.

Nice simple example.  I get it -- guess never had a need to really use it.

Thanks for input.

David

Show quoteHide quote
"Larry Serflaten" <serfla***@usinternet.com> wrote in message
news:%23LpaOM1nJHA.5420@TK2MSFTNGP04.phx.gbl...
>
> "David" <dw85745***@earthlink.net> wrote
>> I don't see the benefit or really purpose of the Container property.
>
> Add two Frame controls and place a Checkbox on one of the frames.
> Paste in the code below and run the program. Click the Checkbox
> a few times....
>
> LFS
>
> Private Sub Check1_Click()
>  If Check1 Then
>    Set Check1.Container = Frame1
>  Else
>    Set Check1.Container = Frame2
>  End If
> End Sub
>
>
>
>
>