Home All Groups Group Topic Archive Search About

Accessing Properties within a Panel

Author
3 Apr 2006 11:42 PM
ally
In VB 2K5 Express I've created a panel named "Configure" with eight
label, and eight combobox controls; and finally a button named
"Apply."

  The label controls are sequentially named Channel0 through Channel7,
and the combobox controls are sequentially named Ch0 through Ch7,
accordingly.

Each combobox contains four items out of which one must be selected.
For example, lets say we choose Channel3 and the corresponding combox
box drops down with these choices:

                        Analog
                        State
                        Counter
                        Pdm

After any or all Channels have been configured, I want to use the
Apply button's click event to process the selections.

My question is, "From within the APPLY buttons click event code, how
can I determine what item each of the eight combobox controls contain?

(I'm kind of  thinking in terms of finding some way to index through
each of the comboboxes using a loop structure, but I don't see any
index value for the combobox controls in the panel.)

Thanks for helping this novice.

Author
4 Apr 2006 7:01 AM
Cor Ligthert [MVP]
Ally,

Combobox.text (do not forget to set them initial to Selectedinded = 0)
As well to set them to dropdownlist

I hope this helps,

Cor


Show quoteHide quote
<ally> schreef in bericht news:8cb332l0htfq0jd1ttcnq28t10h4vo02ua@4ax.com...
> In VB 2K5 Express I've created a panel named "Configure" with eight
> label, and eight combobox controls; and finally a button named
> "Apply."
>
>  The label controls are sequentially named Channel0 through Channel7,
> and the combobox controls are sequentially named Ch0 through Ch7,
> accordingly.
>
> Each combobox contains four items out of which one must be selected.
> For example, lets say we choose Channel3 and the corresponding combox
> box drops down with these choices:
>
>                        Analog
>                        State
>                        Counter
>                        Pdm
>
> After any or all Channels have been configured, I want to use the
> Apply button's click event to process the selections.
>
> My question is, "From within the APPLY buttons click event code, how
> can I determine what item each of the eight combobox controls contain?
>
> (I'm kind of  thinking in terms of finding some way to index through
> each of the comboboxes using a loop structure, but I don't see any
> index value for the combobox controls in the panel.)
>
> Thanks for helping this novice.
>
>
>
Author
4 Apr 2006 12:52 PM
Al Reid
Show quote Hide quote
<ally> wrote in message news:8cb332l0htfq0jd1ttcnq28t10h4vo02ua@4ax.com...
> In VB 2K5 Express I've created a panel named "Configure" with eight
> label, and eight combobox controls; and finally a button named
> "Apply."
>
>   The label controls are sequentially named Channel0 through Channel7,
> and the combobox controls are sequentially named Ch0 through Ch7,
> accordingly.
>
>  Each combobox contains four items out of which one must be selected.
> For example, lets say we choose Channel3 and the corresponding combox
> box drops down with these choices:
>
>                         Analog
>                         State
>                         Counter
>                         Pdm
>
> After any or all Channels have been configured, I want to use the
> Apply button's click event to process the selections.
>
> My question is, "From within the APPLY buttons click event code, how
> can I determine what item each of the eight combobox controls contain?
>
> (I'm kind of  thinking in terms of finding some way to index through
> each of the comboboxes using a loop structure, but I don't see any
> index value for the combobox controls in the panel.)
>
> Thanks for helping this novice.
>
>

You can iterate through the controls on the Panel using the following:
(warning: Air code - not tested)

For Each cal as Control In Configure.Controls
    If TypeOf cal is ComboBox Then

        'Do whatever you need to do with the ComboBoxes.

    End If
Next

I hope this helps.

--
Al Reid
Author
4 Apr 2006 2:51 PM
Larry Lard
Al Reid wrote:
Show quoteHide quote
> <ally> wrote in message news:8cb332l0htfq0jd1ttcnq28t10h4vo02ua@4ax.com...
> > In VB 2K5 Express I've created a panel named "Configure" with eight
> > label, and eight combobox controls; and finally a button named
> > "Apply."
> >
> >   The label controls are sequentially named Channel0 through Channel7,
> > and the combobox controls are sequentially named Ch0 through Ch7,
> > accordingly.
> >
> >  Each combobox contains four items out of which one must be selected.
> > For example, lets say we choose Channel3 and the corresponding combox
> > box drops down with these choices:
> >
> >                         Analog
> >                         State
> >                         Counter
> >                         Pdm
> >
> > After any or all Channels have been configured, I want to use the
> > Apply button's click event to process the selections.
> >
> > My question is, "From within the APPLY buttons click event code, how
> > can I determine what item each of the eight combobox controls contain?
> >
> > (I'm kind of  thinking in terms of finding some way to index through
> > each of the comboboxes using a loop structure, but I don't see any
> > index value for the combobox controls in the panel.)

You're wondering what happened to control arrays, right?

> You can iterate through the controls on the Panel using the following:
> (warning: Air code - not tested)
>
> For Each cal as Control In Configure.Controls
>     If TypeOf cal is ComboBox Then
>
>         'Do whatever you need to do with the ComboBoxes.
>
>     End If
> Next

That works. Or, you can even create your own control array! Remember,
Control is a class like any other, so there's nothing stopping us
creating an array of Control, or even of ComboBox:

'at form level
Private panelCombos() As ComboBox

'at form Load
panelCombos = New Combobox() { Ch0, Ch1, Ch2, Ch3, Ch4, Ch5, Ch6, Ch7 }

'when we want to read the values
Dim iCombo As Integer
For iCombo = 0 To panelCombos.Length - 1
    DoSomethingWith panelCombos(i).SelectedItem
Next

--
Larry Lard
Replies to group please
Author
5 Apr 2006 2:01 PM
ally
Show quote Hide quote
On 4 Apr 2006 07:51:51 -0700, "Larry Lard" <larryl***@hotmail.com>
wrote:
>
>Al Reid wrote:
>> <ally> wrote in message news:8cb332l0htfq0jd1ttcnq28t10h4vo02ua@4ax.com...
>> > In VB 2K5 Express I've created a panel named "Configure" with eight
>> > label, and eight combobox controls; and finally a button named
>> > "Apply."
>> >
>> >   The label controls are sequentially named Channel0 through Channel7,
>> > and the combobox controls are sequentially named Ch0 through Ch7,
>> > accordingly.
>> >
>> >  Each combobox contains four items out of which one must be selected.
>> > For example, lets say we choose Channel3 and the corresponding combox
>> > box drops down with these choices:
>> >
>> >                         Analog
>> >                         State
>> >                         Counter
>> >                         Pdm
>> >
>> > After any or all Channels have been configured, I want to use the
>> > Apply button's click event to process the selections.
>> >
>> > My question is, "From within the APPLY buttons click event code, how
>> > can I determine what item each of the eight combobox controls contain?
>> >
>> > (I'm kind of  thinking in terms of finding some way to index through
>> > each of the comboboxes using a loop structure, but I don't see any
>> > index value for the combobox controls in the panel.)
>
>You're wondering what happened to control arrays, right?
>
>> You can iterate through the controls on the Panel using the following:
>> (warning: Air code - not tested)
>>
>> For Each cal as Control In Configure.Controls
>>     If TypeOf cal is ComboBox Then
>>
>>         'Do whatever you need to do with the ComboBoxes.
>>
>>     End If
>> Next
>
>That works. Or, you can even create your own control array! Remember,
>Control is a class like any other, so there's nothing stopping us
>creating an array of Control, or even of ComboBox:
>
>'at form level
>Private panelCombos() As ComboBox
>
>'at form Load
>panelCombos = New Combobox() { Ch0, Ch1, Ch2, Ch3, Ch4, Ch5, Ch6, Ch7 }
>
>'when we want to read the values
>Dim iCombo As Integer
>For iCombo = 0 To panelCombos.Length - 1
>    DoSomethingWith panelCombos(i).SelectedItem
>Next

Thanks, Al ... mission accomplished on that one.  While speaking of
control arrays,  I also need to create a "cellular" control array.  In
this panel I  have 8 rows by 5 columns and each cell has a textbox
control.  So there are 8 * 5 = 40 cells.  How could I modify your
technique to include a double dimension to fit this scenario?   Namely
something like:

panelCombos = New Combobox(m,n) {textbox(m,n) }

is what I was thinking of, which is just a wild guess on my part.

Thank you very much for your insight!