Gridview1 As GridView
Public Sub Gridview1_MouseMove()
Dim iRow, iCol, iRowFix As Integer
For iRow = 0 To Gridview1.Rows.Max
For iCol = 0 To Gridview1.Columns.Max
Gridview1[iRow, iCol].Background = Color.Default
Gridview1[iRow, iCol].Text = ""
Next
Next
iRowFix = Gridview1.Rowat(Mouse.Y)
If iRowFix = -1 Then iRowFix = Gridview1.Rows.Max
For iCol = 0 To Gridview1.Columns.Max
Gridview1[iRowFix, iCol].Background = Color.Yellow
Gridview1[iRowFix, iCol].Text = "¡Hola!"
Next
End
Public Sub Form_Open()
With Me
.Height = 500
.Width = 600
.Padding = 5
.Center
End With
With Gridview1 = New GridView(Me) As "Gridview1"
.Rows.Count = 20
.Columns.Count = 10
.Expand = True
End With
End
(04-09-2021, 17:07)Grandamakulo escribió: Rápidamente: con Mousemove y Find
(04-09-2021, 19:43)gambafeliz escribió: ¿Esto tiene una fácil solución según tu código? ¿que opinas?
Gridview1 As GridView
Public Sub Gridview1_MouseMove()
Dim iRow, iCol, iRowFix As Integer
Cebra
iRowFix = Gridview1.Rowat(Mouse.Y)
If iRowFix = -1 Then Return
For iCol = 0 To Gridview1.Columns.Max
Gridview1[iRowFix, iCol].Background = 12632256
Next
End
Public Sub Cebra()
Dim iRow, iCol As Integer
Dim bSwitch As Boolean
For iRow = 0 To Gridview1.Rows.Max
For iCol = 0 To Gridview1.Columns.Max
If bSwitch Then
Gridview1[iRow, iCol].Background = 14737632
Else
Gridview1[iRow, iCol].Background = Color.Default
End If
Next
bSwitch = Not bSwitch
Next
End
Public Sub Form_Open()
Dim iLoop As Integer
With Me
.Height = 480
.Width = 600
.Padding = 5
.Arrangement = Arrange.Vertical
.Center
End With
With Gridview1 = New GridView(Me) As "Gridview1"
.Rows.Count = 20
.Columns.Count = 5
.Header = Gridview.Both
.Expand = True
End With
For iLoop = 0 To Gridview1.Columns.Max
Gridview1.Columns[iLoop].Title = Chr(65 + iLoop)
Next
Cebra
End
Public Sub Form_Arrange()
Gridview1.Columns.Width = (Gridview1.Width / Gridview1.Columns.Count) - 10
End
Cita:Esperemos que esto solucione tu problema.
Gridview1 As GridView
Private $last As Integer
Public Sub Form_Open()
Dim iLoop As Integer
$last = -2
With Me
.Height = 480
.Width = 600
.Padding = 5
.Arrangement = Arrange.Vertical
.Center
End With
With Gridview1 = New GridView(Me) As "Gridview1"
.Rows.Count = 20
.Columns.Count = 5
.Header = Gridview.Both
.Expand = True
End With
For iLoop = 0 To Gridview1.Columns.Max
Gridview1.Columns[iLoop].Title = Chr(65 + iLoop)
Gridview1.Columns[iloop].Expand = True
Next
End
Public Sub Gridview1_Data(Row As Integer, Col As Integer)
cebra(Row, Col)
End
Private Sub cebra(Row As Integer, Col As Integer)
If Row Mod 2 = 0 Then
Gridview1[Row, Col].Background = Color.lighter(Color.Background)
Else
Gridview1[Row, Col].Background = Color.Background
Endif
End
Public Sub Gridview1_MouseMove()
Dim iRow, iCol, iRowFix As Integer
iRowFix = Gridview1.Rowat(Mouse.Y)
If iRowFix = -1 Or If iRowfix = $last Then Return 'Si no hay fila o no hemos cambiado de fila aunque se haya movido el ratón, no hacemos nada.
For iCol = 0 To Gridview1.Columns.Max
Gridview1[iRowFix, iCol].Background = Color.lighter(Color.SelectedBackground)
If $last > -1 Then 'Si $Last es -1 es que todavía no tenemos ninguna fila a la que restaurar el color.
cebra($last, iCol)
Endif
Next
$last = iRowfix 'almacenamos el número de la fila modificada
End