|
-
Jan 8th, 2007, 11:10 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [2005] ComboBox
How can I add items to the combobox?
Besides, once i click on certain item of the combobox,certain action would be taken. For example, once i add on second item of combobox, certain command would be sent to the serial port..
Looking forward to receiving feedback here in the forum..thanks a lot !
-
Jan 8th, 2007, 11:15 AM
#2
Re: [2005] ComboBox
Use the .Items.Add or .Items.AddRange methods to add data to your cbo. Is it originally databound?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 8th, 2007, 11:22 AM
#3
Member
Re: [2005] ComboBox
Hi Wence,
To add an item to a combobox:
VB Code:
combobox.Items.Add("item1")
combobox.Items.Add("item2")
To perform an action when the combobox is selected: Select the SelectedIndexChanged event. Whenever any of the combobox items are selected it will fire this event.
VB Code:
Private Sub combobox_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles combobox.SelectedIndexChanged
If cbElevinc.Text = "item1" Then
MsgBox("Perform action for item1")
ElseIf cbElevinc.Text = "item2" Then
MsgBox("Perform action for item2")
End If
End Sub
I hope this helps.
-
Jan 8th, 2007, 11:32 AM
#4
Thread Starter
Hyperactive Member
Re: [RESOLVED] [2005] ComboBox
Thanks for the help..Have not been doing VB for quite some time, now trying to recall back n refresh..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|