Results 1 to 4 of 4

Thread: [RESOLVED] [2005] ComboBox

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Posts
    274

    Resolved [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 !

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  3. #3
    Member
    Join Date
    Jun 2006
    Posts
    55

    Re: [2005] ComboBox

    Hi Wence,

    To add an item to a combobox:

    VB Code:
    1. combobox.Items.Add("item1")
    2. 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:
    1. Private Sub combobox_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles combobox.SelectedIndexChanged
    2.         If cbElevinc.Text = "item1" Then
    3.             MsgBox("Perform action for item1")
    4.         ElseIf cbElevinc.Text = "item2" Then
    5.             MsgBox("Perform action for item2")
    6.         End If
    7.     End Sub

    I hope this helps.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Posts
    274

    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
  •  



Click Here to Expand Forum to Full Width