Results 1 to 4 of 4

Thread: List Box from Combo Box

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2006
    Posts
    2

    Exclamation List Box from Combo Box

    Hi,

    I have a program w/ a DB backend. What I would like to do is fill a listbox based on the selection of the combo box.

    In addition I would like to have two text boxes .text values based on the listbox selection.

    I understand it's based on

    VB Code:
    1. ProjectList_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProjectList.SelectedIndexChanged

    (ProjectList being my combobox) but not sure how to fill the listbox based on this change.

    Thanks
    Last edited by RobDog888; Nov 8th, 2006 at 04:34 PM. Reason: Added [vbcode] tags

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: List Box from Combo Box

    There's no need to handle any events at all. Proper data binding will handle all the control updating for you. I'm not going to say more until you specify which version you're using because the details will be different for each. There are radio buttons provided when you create a thread. Please use them.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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

    Re: List Box from Combo Box

    Is your listbox databound or are you manually populating it in a loop?

    You would need to, rebind a new datasource or repopulate in the loop, passing the new sql query with the combo box selection as part of the where clause to filter the results as your user selected
    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

  4. #4
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: List Box from Combo Box

    In the SelectedIndexChanged event of the ComboBox, you need to connect to the database and query for data that match whatever the combobox's selected item means.
    Once you have the data, just bind it to to the listbox.

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