[quote=111162:@Richard Duke]I encounter problem with the combo box in the process of moving to Cocoa.
When i click on the down arrow the first time, i can see the drop down value is the same as the text area.
When i click on the down arrow the second time, i can see the drop down value is not selected at all.
[/quote]
[quote=111185:@Richard Duke]Micheal, you can certainly can select a row in the drop down menu by simply setting the listIndex of the combo box.
SUB DoSetComboValue(cboRec AS comboBox, vField AS STRING)
DIM i AS Integer
cboRec.text=vField
If Len(vField )<>0 Then
For i = 0 To cboRec.listCount-1
If cboRec.rowtag( i ) = vField Then
cboRec.listIndex=i
Exit
END IF
Next
Else
cboRec.text=""
cborec.ListIndex=-1
END IF
END SUB
[/code][/quote]
I am starting a new thread so this will be easier for future reference. It is important for people who search afterwards so they find answers more logically than looking deep down in an unrelated topic.
Setting the ListIndex in the MouseDown event works but for some reason, immediately after the selection disappear.
Use a timer to keep the ComboBox drop down menu item selected :
[code]Sub Action()
For i as integer = 0 To ComboBox1.listCount-1
If instr(ComboBox1.text,ComboBox1.list( i )) > 0 Then
ComboBox1.listIndex=i
Exit
END IF
next
End Sub
[quote=111254:@Eli Ott]This seems to be a bug. The NSComboBox docs show that if there is a row matching the current text, the row is highlighted on a dropdown:
You cannot add a timer directly to a ComboBox subclass. But you can use a Container Control as master class, into which you place the ComboBox and the timer.
[quote=111259:@Richard Duke]micheal… it work!!! but a pain to do that on each combo…
[/quote]
Put your ComboBoxes in a control set and address them all in the same timer on the page. Here I have three ComboBox named “MyCombobox()” :
Sub Action()
For themember as integer = 0 To 2
For i as integer = 0 To MyComboBox(themember).listCount-1
If instr(MyComboBox(themember).text,MyComboBox(themember).list( i )) > 0 Then
MyComboBox(themember).listIndex=i
Exit
END IF
next
next
End Sub
[quote=111432:@Syed Hassan]For i as integer = 0 To ComboBox1.listCount-1
If instr(ComboBox1.text,ComboBox1.list( i )) > 0 Then
ComboBox1.listIndex=i
Exit
END IF
next[/quote]
thanks Syed and Greg… got it working now… using the timer and addhandler.