Ver Mensaje Individual
  #2 (permalink)  
Antiguo 07/02/2013, 22:22
Avatar de emmax
emmax
 
Fecha de Ingreso: agosto-2010
Ubicación: Sonora
Mensajes: 172
Antigüedad: 14 años, 6 meses
Puntos: 8
Respuesta: DataGridView Ubicarse solo en una celda.

Entendi que tienes los datos en un datagridview y ahi quieres buscar, es correcto?, tal ves te pueda servir el siguiente codigo.

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

Saludos...