Visual Basic.NET - consulta

 
Vista:

consulta

Publicado por wilfot_2 (11 intervenciones) el 12/04/2007 03:09:11
URGENTE ALGUIEN QUE ME AYUDE .TENGO UN COMBOBOX LLAMADO cbtipo_mat EN UN FORMULARIO DE CONSULTA.
Y DESEO QUE CUANDO EL USUARIO ESCRIBA UNA PALABRA,O ASI SEA UNA SOLA LETRA,AL DESPLEGAR EL COMBOBOX ME MUESTRE TODO LO RELACIONADO CON LA PALABRA ESCRITA ,O CON LA LETRA ESCRITA EN EL COMBOBOX.
TENGO ALGO DE CODIGO ESCRITO.
Private Sub cbtipo_mat_TabIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbtipo_mat.TabIndexChanged

'Realizar la búsqueda según la columna
Dim filtro As String
'Dim dv As DataView
Try
If dv.Table.Columns(Me.cbtipo_mat.Text).DataType.Name.ToLower = "string" Then
filtro = Me.cbtipo_mat.Text & " like '" & Me.cbtipo_mat.Text & "%'"
Else
If Me.cbtipo_mat.Text.Trim.Length > 0 Then
filtro = Me.cbtipo_mat.Text & " = " & Me.cbtipo_mat.Text
End If
End If
dv.RowFilter = filtro
Catch ex As Exception
MsgBox(ex.Message)

End Try
End Sub
PEOR NO ME ESTA FUNCINANDO.
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:consulta

Publicado por haver (196 intervenciones) el 12/04/2007 22:57:35
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Try
dim conexion as new oledb.oledbconexion (" TU string de conexion ")
Dim DSConsulta As New DataSet
Dim oadaptador as new dataadapter
Dim ocommand as new oledb.oledbcommand("Select ID FROM Activities WHERE
ID LIKE '101%' And Name Like '%" & TextBox1.Text & "%'", conexion)
oadaptador.selectcommand 0 ocommand
oadaptador.fill (dsconsulta,"ID")

Me.DataGridView1.DataSource = Dsconsulta
Me.DataGridView1.DataMember = DSConsulta.Tables("Activities").TableName

DataGridView1.AutoResizeColumn(0)
DataGridView1.AutoResizeColumn(1)
Catch ex As Exception
MsgBox("Error en text change activities" & ex.Message)
End Try
End Sub
este codigo te llena el datagrid con los valores que contengan 101 ya se al final principio o medio y el nombre sea igual al del textbox donde se esta ingresando la informacion
adecualo a tus necesidades
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