Ver Mensaje Individual
  #6 (permalink)  
Antiguo 15/05/2013, 18:55
Avatar de emmax
emmax
 
Fecha de Ingreso: agosto-2010
Ubicación: Sonora
Mensajes: 172
Antigüedad: 14 años, 5 meses
Puntos: 8
Respuesta: Filtro en datagridview con textbox

Hola, no se si te sirva pero yo tengo algo parecido en unos programas que hice y lo manejo de la siguiente manera, lleno el Grid con todos los datos que tengo en la Bd, ejemplo articulos, y con una funcion que hice hago una busqueda dentro del mismo grid, no se si te sirva o a lo mejor haciendole algunos cambios puedes adaptarlo a lo que necesitas, te dejo la funcion.

Código VB.NET:
Ver original
  1. Public Function Buscar(ByVal TextoABuscar As String, ByVal Columna As String, ByRef grid As DataGridView) As Boolean
  2.         Dim encontrado As Boolean = False
  3.         If TextoABuscar = String.Empty Then Return False
  4.         If grid.RowCount = 0 Then Return False
  5.         grid.ClearSelection()
  6.         If Columna = String.Empty Then
  7.             For Each row As DataGridViewRow In grid.Rows
  8.                 For Each cell As DataGridViewCell In row.Cells
  9.                     If cell.Value.ToString() = TextoABuscar Then
  10.                         row.Selected = True
  11.                         Return True
  12.                     End If
  13.                 Next
  14.             Next
  15.         Else
  16.             For Each row As DataGridViewRow In grid.Rows
  17.                 If row.IsNewRow Then Return False
  18.                 If row.Cells(Columna).Value.ToString() = TextoABuscar Then
  19.                     row.Selected = True
  20.                     Return True
  21.                 End If
  22.             Next
  23.         End If
  24.         Return encontrado
  25.     End Function