Results 1 to 6 of 6

Thread: more than one choice in ListBox.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2013
    Posts
    31

    more than one choice in ListBox.

    Hi all,

    I have a ListBox with a list of Authors in it on a form that is linked to a database.At the moment I click on one of the Authors and I get the records for that author from my database into my Datagrid.

    Is there a way that I could click on more than one Author and get more records up from the database into the datagrid.
    I did try switching the SelectionMode property to MultiSimple and then MiltiExtended.but this didn't work,so I assume there must be a way to do this with code.Any suggestion much appreciated.
    Greetings

    WC

  2. #2
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,712

    Re: more than one choice in ListBox.

    I did try switching the SelectionMode property to MultiSimple and then MiltiExtended.but this didn't work
    How did it not work? Were you able to select multiple entries?

    Once you have multiple entries selected, you need to iterate the listbox's SelectedItems or SelectedIndexs and process each item individually.

    Code:
    For Each item As Object In Me.ListBox1.SelectedItems
    
          MessageBox.Show(item.ToString)
    
    Next
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2013
    Posts
    31

    Re: more than one choice in ListBox.

    Hi Kebo,
    Thanyou for the reply

    I tried your code and it came up with a MsgBox displaying the selection I had made in the ListBox.Do I have to modify this some way in order to get the data from database into the datagrid.

    Kind regards
    wc

  4. #4
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,712

    Re: more than one choice in ListBox.

    Quote Originally Posted by windowcleaner View Post
    Hi Kebo,
    Thanyou for the reply

    I tried your code and it came up with a MsgBox displaying the selection I had made in the ListBox.Do I have to modify this some way in order to get the data from database into the datagrid.

    Kind regards
    wc
    Why yes. There is however a very very slight probability you can get the data by displaying the message box, but it about the same probability of walking through a wall (which there is a very very very slight probability of doing).

    At the moment I click on one of the Authors and I get the records for that author
    What ever you do to get one record, you need to repeat for each of the selections.
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Mar 2013
    Posts
    31

    Re: more than one choice in ListBox.

    Has anyone got any useful suggestion to this problem

  6. #6
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,712

    Re: more than one choice in ListBox.

    Quote Originally Posted by windowcleaner
    At the moment I click on one of the Authors and I get the records for that author from my database into my Datagrid.
    Quote Originally Posted by windowcleaner
    I tried your code and it came up with a MsgBox displaying the selection I had made in the ListBox.Do I have to modify this some way in order to get the data from database into the datagrid.
    Show us how you are populating the grid with a single record.
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

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