By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,552 Members | 905 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,552 IT Pros & Developers. It's quick & easy.

Accessing Properties within a Panel

P: n/a
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.

Apr 3 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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
<ally> schreef in bericht news:8c********************************@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.

Apr 4 '06 #2

P: n/a

<ally> wrote in message news:8c********************************@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
Apr 4 '06 #3

P: n/a

Al Reid wrote:
<ally> wrote in message news:8c********************************@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

Apr 4 '06 #4

P: n/a
On 4 Apr 2006 07:51:51 -0700, "Larry Lard" <la*******@hotmail.com>
wrote:

Al Reid wrote:
<ally> wrote in message news:8c********************************@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!
Apr 5 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.