listbox issues

grndzyro
09-11-2003, 11:35 AM
Ok here is a my issues...though, this may be some easy answers for some people, obviously though I am not some people..

First here is the code I am working with

VB

Dim varVals as Variant
Dim varVal as Variant
Dim varNam as Variant
Dim varNams as Variant
Dim varMails as Variant
Dim varMail as Variant

lstResults.ListIndex=0

Set result = results.Item(lstResults.List(lstResults.ListIndex))
strVals = result.FieldValue("cn")
strNams = result.FieldValue("fullname")
strMails = result.FieldValue("mail")

For Each varVal In varVals
lstVals.AddItem varVal
Next
For Each varNam in varNams
lstNames.AddItem varNam
Next
For Each varMail in varMails
lstMail.AddItem varMail
Next


ok the "result" is pulled from an LDAP component, but should not be an issue since my issues are with the list boxes...
I have 4 listboxes as you can see be the code
1st is lstResults - this brings back my query of items
2nd is lstVals which returns a value depending on what is selected in lstResults
same goes for the last 2, lstNames and lstMail
When I click directly on the entry in the lstResults box, the other list boxes populate fine, if I use the arrow key and arrrow up or down it seem to be back 1 from where it should be(meaning I hit up, it doesnt move in the lstVals but does in the lstResult, I hit up again and then it moves in all making the lstResults different than the lstVals (this is probably simple,..)
The other part is, I want to hide the lstResults, but be able to hit the arrow key to populate the other list boxes accordingly, problem is, when I click my search button, I have to then click on the lstResults to be able to use the arrow keys, how can I send focus to the lstResults on cmd_Click???

Sorry its lengthy, but this will make life so much easier on me if I can get this ldap query going well...Thanks

Lar_19
09-11-2003, 02:30 PM
You can synchronize the last three list box selections by setting their ListIndex property to match that of lstResults. As far as setting the focus to a hidden control, this can't be done with the visible property. You will have to move it out of view instead. Here is a little demo that illustrates what I mean...Option Explicit

Private Sub Form_Load()
' Fill the lists with dummy data.
Dim i As Integer
For i = 0 To 9
lstResults.AddItem "Item #" & i + 1
lstVals.AddItem "Item #" & i + 1
lstNames.AddItem "Item #" & i + 1
lstMail.AddItem "Item #" & i + 1
Next i
End Sub

Private Sub lstResults_Click()
' Snychrhronize the the last three lists with the first.
lstVals.ListIndex = lstResults.ListIndex
lstNames.ListIndex = lstResults.ListIndex
lstMail.ListIndex = lstResults.ListIndex
End Sub

Private Sub Command1_Click()
' Can't set focus to a control with it's visible
' property set to false so move it out of view.
lstResults.Left = Me.Left + (lstResults.Width * 2)
lstResults.SetFocus
End Sub

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum