Private Declare Function SetProp Lib "user32.dll" Alias "SetPropA" (ByVal hwnd As Long, ByVal lpString As String, ByVal hData As Long) As Long
Private Sub Form_Load()
Dim N, NN As Integer
'\\Preparar grelha
With GrHistorico
.Cols = 8
.Rows = 200
.FixedCols = 0
.FixedRows = 1
.TextMatrix(0, 0) = "Data"
.TextMatrix(0, 1) = "Utilizador"
.TextMatrix(0, 2) = "Janela"
.TextMatrix(0, 3) = "Operação"
.TextMatrix(0, 4) = "Documento"
.TextMatrix(0, 5) = "Divisa"
.TextMatrix(0, 6) = "ID int."
.TextMatrix(0, 7) = "Valorização"
'\\Agora as medidas
.ColWidth(0) = 1700
.ColWidth(1) = 1200
.ColWidth(2) = 4500
.ColWidth(3) = 4500
.ColWidth(4) = 4500
.ColWidth(5) = 1000
.ColWidth(6) = 1000
.ColWidth(7) = 1300
'\\Alinhamentos das colunas
.ColAlignment(0) = flexAlignCenterCenter
.ColAlignment(1) = flexAlignLeftCenter
.ColAlignment(2) = flexAlignLeftCenter
.ColAlignment(3) = flexAlignLeftCenter
.ColAlignment(4) = flexAlignLeftCenter
.ColAlignment(5) = flexAlignCenterCenter
.ColAlignment(6) = flexAlignRightCenter
.ColAlignment(7) = flexAlignRightCenter
'\\Alinhamentos dos cabeçalhos
.FixedAlignment(0) = flexAlignCenterCenter
.FixedAlignment(1) = flexAlignLeftCenter
.FixedAlignment(2) = flexAlignLeftCenter
.FixedAlignment(3) = flexAlignLeftCenter
.FixedAlignment(4) = flexAlignLeftCenter
.FixedAlignment(5) = flexAlignCenterCenter
.FixedAlignment(6) = flexAlignRightCenter
.FixedAlignment(7) = flexAlignRightCenter
'populate some rows and cols
For N = 0 To 7
For NN = 1 To 199
.TextMatrix(NN, N) = "Just for testing ..."
Next NN
Next N
End With
SubClassMsGRID GrHistorico, Picture1
End Sub
Private Sub Form_Resize()
On Error Resume Next
GrHistorico.Move 300, 300, Me.ScaleWidth - 600, Me.ScaleHeight - 600
End Sub
Private Sub Form_Unload(Cancel As Integer)
UnSubClassMsGRID GrHistorico.hwnd
End Sub
Private Sub GrHistorico_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
With GrHistorico
SetProp .hwnd, "Click", .Row
.Refresh
End With
End Sub
ignore the subclassing stuff
Last edited by dglienna; December 12th, 2007 at 04:21 PM.
Last question...
The first column of the grid is grey/gray in color/colour...
How can I make have the same color and behavior of the rest of the columns?
Something is wierd with my flexgrid.
I set selectionmode to flexSelectByRow
in flexgrid click event I want to get the row that the user clicked on.
however I notice that every thing from the first row to the row that the user clicked on is selected and the .row property is 1....
Why is the previous selected row still highlighted as a selected row?
Is there a flag for multiple selection that I'm not setting?
I set the flag AllowBigSelection to false...
But every thing above the current mouse click row is highlighted...
Last edited by JustSomeGuy; December 14th, 2007 at 02:57 PM.
Option Explicit
Private Sub Command1_Click()
Dim i As Integer
For i = 1 To flx.Rows - 1
If i Mod 2 = 0 Then
With flx
.FillStyle = flexFillRepeat
.Row = i
.RowSel = i
.Col = 1
.ColSel = .Cols - 1
.CellBackColor = vbRed
.CellForeColor = vbWhite
End With
End If
Next i
flx.Row = 1
End Sub
Private Sub Form_Load()
Dim i As Integer, j As Integer
With flx
For i = 1 To flx.Rows - 1
For j = 0 To .Cols - 1
.TextMatrix(i, j) = i & ", " & j
Next j
Next i
End With
End Sub
Bookmarks