Visual Basic - Combo

Life is soft - evento anual de software empresarial
 
Vista:

Combo

Publicado por Kazurrete (2 intervenciones) el 15/06/2001 09:50:21
Tengo un combo con unos valores del ItemData y no se como seleccionar mediante codigo uno de los elementos y que se vea....
me expico tengo un combo con los valores de itemdata 4, 7, 12, y estos muestran en pantalla CUATRO, SIETE, DOCE y quiero,
mediante codigo (sabiendo el valor 7) poner mostrar en el combo SIETE, entendeis....

Joer ke mal me explico....

grasiassss----...
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Combo

Publicado por isidroalmaguer (288 intervenciones) el 15/06/2001 16:38:50
hola...
hay te va este codigo...

Sub pubSeleccionaElemento(pLista As Control, pLlave As Variant, Optional pEsString As Boolean)
' encuentra un elemento en un Listbox o Combobox
Dim i As Integer

If IsMissing(pEsString) Then
pEsString = False
End If

If pEsString Then
For i = 0 To pLista.ListCount - 1
If LCase(Left(pLista.List(i), Len(pLlave))) = LCase(pLlave) Then
pLista.TopIndex = i
Exit For
End If
Next
Else
If TypeOf pLista Is ComboBox Then
pLista.ListIndex = -1
For i = 0 To pLista.ListCount - 1
If pLista.ItemData(i) = pLlave Then
pLista.ListIndex = i
Exit For
End If
Next
Else
For i = 0 To pLista.ListCount - 1
If pLista.ItemData(i) = pLlave Then
pLista.Selected(i) = True
Exit For
End If
Next
End If
End If

End Sub

y asi lo llamas

pubSeleccionaElemento cboProducto, iProductId

espero te ayude

saludos
isidroalmaguer
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar