-
Dear all,
I am new using flexgrid. I want to be able to resize the columns and rows in flexgrid by code. How can I do it?
Secondly, I want to use bitmap images in the grid cells. How do I address a cell in the flexgrid and put a picture into it. It was easier when I used MS Grid (GRID32.OCX) in VB4.
I would really appeciate some help. Thank you.
Deiva
-
I can help you with the first bit anyway.
MSFlexGrid1.Colwidth(0) = 500
The columns are indexed starting at zero so you need to reference them in brackets as shown. I'm pretty sure it's the same for height.
-
1. Here is a Generic routine I've put together a while back:
Code:
Public Function ResizeGrid(pGrid As MSFlexGrid, pForm As Form)
Dim intRow As Integer
Dim intCol As Integer
With pGrid
For intCol = 0 To .Cols - 1
For intRow = 0 To .Rows - 1
If .ColWidth(intCol) < pForm.TextWidth(.TextMatrix(intRow, intCol)) + 100 Then
.ColWidth(intCol) = pForm.TextWidth(.TextMatrix(intRow, intCol)) + 100
End If
Next
Next
End With
End Function
Then just call this routine like this:
ResizeGrid MSFlexGrid1, Form1
2. Let's say you want to put picture into the First column of the second row:
Code:
With MSFlexGrid1
.Col = 0
.Row = 1
Set CellPicture = LoadPicture("C:\MyPicture.bmp")
End With