Results 1 to 7 of 7

Thread: listbox problems

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2004
    Posts
    23

    listbox problems

    hi there

    i have three listboxes on my form

    lstES, lstNES, lstGC

    actually all the three listboxes are aligned one next to the other
    The listboxes contains different subjects in each one of them

    Actually when i am selecting an item in any one of the listboxes, i wish to have the selected index = -1 in the other two listboxes.

    i have tried different codes, but i couldnt possibly make it out. Can anyone help me plz.

    Thanks

  2. #2
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961
    write code in Validated event of all list boxes.

    In 1st ListBox:
    LB2.SelectedIndex =-1
    LB3.SelectedIndex =-1

    In 2nd ListBox:
    LB1.SelectedIndex =-1
    LB3.SelectedIndex =-1

    In 3rd ListBox:
    LB1.SelectedIndex =-1
    LB2.SelectedIndex =-1

    hope is helps

    Regards

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2004
    Posts
    23
    in which event should i write them ? plz

    thanks n regards
    virusdude

  4. #4
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961
    i mentioned it. In "Validated" Event. Or maybe there's something like "IndexChanged"

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Mar 2004
    Posts
    23
    I tried it in almost all the events that i could possibly find as being a one that will make it work, but still i couldnt do it

    Could anyone help plz.

    i tried on validated, indexchanged, mousedown, mouseup but didnt work

    Thanks

  6. #6
    Lively Member ayan's Avatar
    Join Date
    Jan 2004
    Posts
    112
    halu,

    i don't know if i understand the prob correctly but just as pvbangera mentioned, you have to specify for each event.
    mousedown is working for this...

    VB Code:
    1. Private Sub ListBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown
    2.         ListBox2.SelectedIndex = -1
    3.         ListBox3.SelectedIndex = -1
    4.         TextBox1.Text = ListBox1.SelectedIndex
    5.         TextBox2.Text = ListBox2.SelectedIndex
    6.         TextBox3.Text = ListBox3.SelectedIndex
    7.     End Sub
    8.  
    9.     Private Sub ListBox2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox2.MouseDown
    10.         ListBox1.SelectedIndex = -1
    11.         ListBox3.SelectedIndex = -1
    12.         TextBox1.Text = ListBox1.SelectedIndex
    13.         TextBox2.Text = ListBox2.SelectedIndex
    14.         TextBox3.Text = ListBox3.SelectedIndex
    15.     End Sub
    16.  
    17.     Private Sub ListBox3_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox3.MouseDown
    18.         ListBox1.SelectedIndex = -1
    19.         ListBox2.SelectedIndex = -1
    20.         TextBox1.Text = ListBox1.SelectedIndex
    21.         TextBox2.Text = ListBox2.SelectedIndex
    22.         TextBox3.Text = ListBox3.SelectedIndex
    23.     End Sub
    i just put something like 3 textboxes to monitor their corresponding selected index values...

    hope this helps... if not, sorry for bothers...

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Mar 2004
    Posts
    23
    Thanks dude

    it did work

    THanks

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