
msflexgrid color fila
Publicado por valeria (5 intervenciones) el 26/08/2013 23:23:35
tengo un texbox donde hago un filtrado ingreso el nombre y aparece
la fila encontrada,resaltada con un color .lo que deseo es desplazar fila resaltada con las teclas keydowun/keyup(arriba/abajo) dentro del msflexgrid despues de hacer el filtrado pero no se como hacerlo.pierdo el foco
Dim dbconex As New Connection
Private Sub Form_Load()
dbconex.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\AZUCENA\Escritorio\kgv\bd1.mdb;Persist Security Info=False"
Me.MSHFlexGrid1.SelectionMode = flexSelectionByRow
End Sub
Private Sub MSHFlexGrid1_SelChange()
On Error Resume Next
Me.MSHFlexGrid1.Refresh
Me.MSHFlexGrid1.TopRow = 1
Me.MSHFlexGrid1.RowSel = Me.MSHFlexGrid1.Row
Me.Text1.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 1)
End Sub
Private Sub txtbusqueda_Change()
Dim rsConex As New Recordset
Dim strSQL As String
strSQL = "Select * from lista Where nombre like '" + Trim(txtbusqueda) & "%' "
rsConex.Open strSQL, dbconex, adOpenStatic, adLockBatchOptimistic
Set Me.MSHFlexGrid1.DataSource = rsConex
If Me.MSHFlexGrid1.Row = 0 Then
Me.Text1.Text = Empty
Exit Sub
End If
Call llamar
End Sub
Sub llamar()
On Error Resume Next
Dim i As Integer
Dim j As Integer
Me.Text1.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 1)
With MSHFlexGrid1
For i = 0 To 4
For j = 0 To 4
If MSHFlexGrid1.TextMatrix(i, 1) = txtbusqueda Then
.Col = j
.Row = i
Me.MSHFlexGrid1.FocusRect = flexFocusNone
Me.MSHFlexGrid1.HighLight = flexHighlightWithFocus
Me.MSHFlexGrid1.SelectionMode = flexSelectionByRow
Me.MSHFlexGrid1.FocusRect = flexFocusNone
' PONE EL COLOR ROJO EN LA FILA
.CellBackColor = &HC0C0C0
End If
Next j
Next i
End With
End Sub
la fila encontrada,resaltada con un color .lo que deseo es desplazar fila resaltada con las teclas keydowun/keyup(arriba/abajo) dentro del msflexgrid despues de hacer el filtrado pero no se como hacerlo.pierdo el foco
Dim dbconex As New Connection
Private Sub Form_Load()
dbconex.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\AZUCENA\Escritorio\kgv\bd1.mdb;Persist Security Info=False"
Me.MSHFlexGrid1.SelectionMode = flexSelectionByRow
End Sub
Private Sub MSHFlexGrid1_SelChange()
On Error Resume Next
Me.MSHFlexGrid1.Refresh
Me.MSHFlexGrid1.TopRow = 1
Me.MSHFlexGrid1.RowSel = Me.MSHFlexGrid1.Row
Me.Text1.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 1)
End Sub
Private Sub txtbusqueda_Change()
Dim rsConex As New Recordset
Dim strSQL As String
strSQL = "Select * from lista Where nombre like '" + Trim(txtbusqueda) & "%' "
rsConex.Open strSQL, dbconex, adOpenStatic, adLockBatchOptimistic
Set Me.MSHFlexGrid1.DataSource = rsConex
If Me.MSHFlexGrid1.Row = 0 Then
Me.Text1.Text = Empty
Exit Sub
End If
Call llamar
End Sub
Sub llamar()
On Error Resume Next
Dim i As Integer
Dim j As Integer
Me.Text1.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 1)
With MSHFlexGrid1
For i = 0 To 4
For j = 0 To 4
If MSHFlexGrid1.TextMatrix(i, 1) = txtbusqueda Then
.Col = j
.Row = i
Me.MSHFlexGrid1.FocusRect = flexFocusNone
Me.MSHFlexGrid1.HighLight = flexHighlightWithFocus
Me.MSHFlexGrid1.SelectionMode = flexSelectionByRow
Me.MSHFlexGrid1.FocusRect = flexFocusNone
' PONE EL COLOR ROJO EN LA FILA
.CellBackColor = &HC0C0C0
End If
Next j
Next i
End With
End Sub
Valora esta pregunta


0