Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations danielledunham on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

list box / text box

Status
Not open for further replies.

kenndot

Programmer
Joined
May 15, 2001
Messages
316
Location
US
I want to connect the info in a listbox to two text boxes so whatever is selected in the listbox it will appear in the text boxes. I have two columns in the listbox.

How do I do this?
 
The basic assignment would be:

Thisform.text1.value = thisform.list1.value

But where you put the code to do this can be in different places. It can go in the valid of the listbox, or in lostfocus, or in the interactivechangeevent.
If you want to show the value of the listbox in the text box as you move through the listbox put it in the interactivechangeevent.
Attitude is Everything
 
I got the first column to work (the listbox has two columns) using

ThisForm.txtGood.value = this.list(nCnt) -
and that works fine

but I can't seem to access the value in the second column.... any ideas there?
 
I've also tried changing the boundcolumn to 2 but that doesn't change anything.

is there some setting or property I'm missing?
 
Look at the List property on the listbox.

some info for you:
Control.List(nRow [, nCol])[ = cChar]

nRow

Specifies the row of the item to be retrieved using the display order. For example, nRow = 3 specifies the third row shown in the list.

nCol

Specifies the column of the item to be retrieved using the display order. For example, nCol = 2 specifies the second column shown in the list. If nCol is not specified, the List property retrieves the first column by default. Only specify nCol for ComboBox and ListBox controls that have more than one column.

below is an example to loop through the listbox

FOR nCnt = 1 TO ThisForm.lstListBox1.ListCount
IF ThisForm.lstListBox1.Selected(nCnt) && Is item selected?
? SPACE(5) + ThisForm.lstListBox1.List(nCnt) && Show item
ENDIF
ENDFOR
Attitude is Everything
 
Thanks Danceman, I ended up doing something similar but this is helpful.

This is what I ended up with in case anyone has the same problem.

rowNumber = ''
indexNum = THIS.LISTINDEX
numColumns = THIS.COLUMNCOUNT

FOR nCnt3 = 1 TO numColumns
IF nCnt3 = 1
THISFORM.txtGood.VALUE = THIS.LIST(indexNum, nCnt3)
ENDIF
IF nCnt3 = 2
THISFORM.txtBad.VALUE = THIS.LIST(indexNum, nCnt3)
ENDIF
ENDFOR
 
How do I comma delineate the values of my extended select listbox to push them into a text box?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top