Results 1 to 3 of 3

Thread: 2 Listboxed populating FlexGrid [Resolved]

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2004
    Location
    Canada
    Posts
    95

    Resolved 2 Listboxed populating FlexGrid [Resolved]

    I have 2 Listboxes, a datagrid with 2 colums and an add button on a form.
    I want it when a item on the 1st listbox(source) is clicked and the add button is pressed, it gets added to the first column in the flexgrid. When an item from the second listbox(destination) is clicked and the add button is pressed it will add the item to the second column in the flexgrid.

    I have that working alright, but i want it so that only 1 listbox can be clicked. Right now it is possible to have 1 item from the 1st listbox selected while one item from the second listbox is also selected. I want it so that only 1 listbox can have items click on it at 1 time, but be able to switch back and forth.

    Heres the code i have so far.
    VB Code:
    1. Private Sub cmdAdd_Click()
    2.  
    3.  
    4. If lstDest.ListIndex <> -1 Then
    5. lstSource.ListIndex = -1
    6.    Item = lstDest.Text
    7.    If grdFields.TextMatrix(0, 1) = "" Then
    8.       dGridRow = 0
    9.       grdFields.TextMatrix(dGridRow, 1) = Item
    10.    Else
    11.       dGridRow = dGridRow + 1
    12.       grdFields.TextMatrix(dGridRow, 1) = Item
    13.    End If
    14. End If
    15.  
    16.  
    17. If lstSource.ListIndex <> -1 Then
    18. lstDest.ListIndex = -1
    19.     Item = lstSource.Text
    20.     If grdFields.TextMatrix(0, 0) = "" Then
    21.        sGridRow = 0
    22.        grdFields.TextMatrix(sGridRow, 0) = Item
    23.     Else
    24.        sGridRow = sGridRow + 1
    25.        grdFields.TextMatrix(sGridRow, 0) = Item
    26.     End If
    27. End If
    28. End Sub

    -Ryan
    Last edited by RyanEllis; Mar 17th, 2005 at 10:38 AM.

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: 2 Listboxed populating FlexGrid

    VB Code:
    1. Private Sub lstSource_Click()
    2.     If lstSource.ListIndex >= 0 Then
    3.         lstDest.ListIndex = -1
    4.     End If
    5. End Sub
    6.  
    7. Private Sub lstDest_Click()
    8.     If lstDest.ListIndex >= 0 Then
    9.         lstSource.ListIndex = -1
    10.     End If
    11. End Sub

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2004
    Location
    Canada
    Posts
    95

    Re: 2 Listboxed populating FlexGrid

    Thanks,
    Worked Perfect, a lot easier to do than i though.

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