can some plz help this newbie,,,,,combo boxes in vb.net

frankwhite

Well-known member
Joined
Nov 30, 2004
Messages
49
Programming Experience
Beginner
i need help please....combo box in vb.net
i was wondering can any one help me please...

ive entered some items in the collections of the combo boxes...

i need a short code to do the follwing 2 things:

1- once a item is selected from the combo box a image should be shown in the picture box,

2- once the item is selected it should also be shown in the list box...

can some 1 post up the code, a.s.a.p

thanx :confused:
 
hey frank its me mar_zim from vbf...haven't my code work?

i dunno what happend to your machine why the hell you dont have an imagelist.
 
Hi Frank,
I think all you really need to do is add an event to the combo box.
Then within that event, you insert your code to update the listbox and image.

Im not sure which event it would be. probably something like "on change"

Hope this helps
 
change pictureBox image in runtime.

Hi Frank,

i hope i get your question..:)
VB.NET:
[size=2]
[/size][size=2][color=#0000ff]Private[/color][/size][size=2][color=#0000ff]Sub[/color][/size][size=2] ComboBox1_SelectedIndexChanged([/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] sender [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.Object, [/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] e [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.EventArgs) [/size][size=2][color=#0000ff]Handles[/color][/size][size=2] ComboBox1.SelectedIndexChanged
 
[color=green]'if the selected text is "Orange" (change to the text you want)[/color]
[/size][size=2][color=#0000ff]If[/color][/size][size=2] ComboBox1.SelectedItem = "Orange" [/size][size=2][color=#0000ff]Then
 
[color=seagreen]'specify the location of your picture[/color]
[/color][/size][size=2]PictureBox1.Image = Image.FromFile("C:\Orange.jpg")
[/size][size=2][color=#0000ff]ElseIf[/color][/size][size=2] ComboBox1.SelectedItem = "Apple" [/size][size=2][color=#0000ff]Then
[/color][/size][size=2]PictureBox1.Image = Image.FromFile("C:\Apple.jpg")
[/size][size=2][color=#0000ff]ElseIf[/color][/size][size=2] ComboBox1.SelectedItem = "Banana" [/size][size=2][color=#0000ff]Then
[/color][/size][size=2]PictureBox1.Image = Image.FromFile("C:\banana2.jpg")
[/size][size=2][color=#0000ff]Else
[/color][/size][size=2]PictureBox1.Image = [/size][size=2][color=#0000ff]Nothing [color=seagreen]'nothing display in the picture box[/color]
 
[/color][/size][size=2][color=#0000ff]End[/color][/size][size=2][color=#0000ff]If
[color=seagreen]'add the items that has already selected into ListBox[/color] 
[/color][/size][size=2]ListBox1.Items.Add(ComboBox1.SelectedItem)
[/size][size=2][color=#0000ff]End[/color][/size][size=2][color=#0000ff]Sub
[/color][/size]
hope this is what you want ..:)

combo.jpg
 
Last edited:
thanx pianoee ive done that coding...

i need help....

i have a 3 combo boxes and 3 radio button.....

every time an item is selected from the combo box......i want the radio buttons to stay clear until an radio button is selected..

thanxx
 
Frank, just double click the combo box you have, it will automatically generate the codoing of selectedIndexChanged event at the code behind, then you just need to add the code for what will happen when selectedIndexChanged.

VB.NET:
 [size=2][color=#0000ff]
Private[/color][/size][size=2][color=#0000ff]Sub[/color][/size][size=2] ComboBox1_SelectedIndexChanged([/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] sender [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.Object, [/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] e [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.EventArgs) [/size][size=2][color=#0000ff]Handles[/color][/size][size=2] ComboBox1.SelectedIndexChanged[/size]
[size=2][color=green]'add this 3 lines of code[/color][/size]
[size=2]RadioButton1.Checked = [/size][size=2][color=#0000ff]False[/color][/size]
[size=2]RadioButton2.Checked = [/size][size=2][color=#0000ff]False[/color][/size]
[size=2]RadioButton3.Checked = [/size][size=2][color=#0000ff]False
[/color][/size][size=2][color=#0000ff]End[/color][/size][size=2][color=#0000ff]Sub
 
[/color][/size]
* same coding apply to all your combo box...
*radio button needs to put in groups box in order to let it only selected one at a time.

:) hehe.. gambateh!
with thanks...
 
Back
Top