Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2004
    Location
    Reading, UK
    Posts
    16

    Question Unanswered: List Box problem - need selected item data on change event

    I have a form containing a list box and want to populate a textbox with some of the data from the selected list box item when a user clicks on the item.

    The property lstResults.Selected(lRow) returns true (-1) if the item is selected and false otherwise. This works fine if I reference the property from another event (e.g. the click event of another text box). However if you try to reference lstResults.Selected(lRow) from the click or after update events of the actual list box, they always return false, even when the item is definitely selected.

    I want to update the text box every time a user clicks on an item in the list box so ideally I need to be able to "see" the lstResults.Selected(lRow) property on an event triggered by the user selecting an item (click or update).

    Does anyone know a way around this please?

  2. #2
    Join Date
    Sep 2001
    Location
    Chicago, Illinois, USA
    Posts
    601
    Have you looked at the Column property of the listbox?
    Ken

    Maverick Software Design

    (847) 864-3600 x2

  3. #3
    Join Date
    Apr 2004
    Location
    Kingsland, Georgia
    Posts
    231

    Re: List Box problem - need selected item data on change event

    Originally posted by sean_fackrell
    I have a form containing a list box and want to populate a textbox with some of the data from the selected list box item when a user clicks on the item.

    The property lstResults.Selected(lRow) returns true (-1) if the item is selected and false otherwise. This works fine if I reference the property from another event (e.g. the click event of another text box). However if you try to reference lstResults.Selected(lRow) from the click or after update events of the actual list box, they always return false, even when the item is definitely selected.

    I want to update the text box every time a user clicks on an item in the list box so ideally I need to be able to "see" the lstResults.Selected(lRow) property on an event triggered by the user selecting an item (click or update).

    Does anyone know a way around this please?
    if you are trying to put the clicked item into the textbox everytime the listbox is clicked, just put the following code into your lstBox_Click() event:

    Code:
    txtBox = lstBox.ItemData(lstBox.ListIndex())
    the .ListIndex property gives the row number of the selected item, and .ItemData gives the data of the item at the given row number. hope this helps.

  4. #4
    Join Date
    Apr 2004
    Location
    Reading, UK
    Posts
    16

    Talking

    That's exactly what I was after. Cheers for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •