How can I set a specific column width in my flexgrid? In addition, is it possible to click on a row, then click a command button and open a new form and display that particular record?
Printable View
How can I set a specific column width in my flexgrid? In addition, is it possible to click on a row, then click a command button and open a new form and display that particular record?
intCol = MSFlexGrid1.col
intRow = MSFlexGrid1.row
Those would give you the col and row of the cell you cliked on. In reverse:
MSFlexGrid1.row = intRow
MSFlexGrid1.col = intCol
You can use these to cycle through the grid if you want or retrieve the info from a database.
Use the ColWidth() Property to specify the Width of a Specific Cell, ie.
MSFlexGrid1.ColWidth(0) = 500
You can just Reference the MSFlexGrid1 Object on Form1 from Form2, ie.
Add a Textbox called txtField to Form2 and set its Index Property to Zero..
In Form1..
In Form2..Code:Private Sub Form_Load()
Dim iIndex As Integer
With MSFlexGrid1
.SelectionMode = flexSelectionByRow
.FocusRect = flexFocusNone
.Cols = 4
.Rows = 5
.FixedCols = 0
.FixedRows = 0
For iIndex = 0 To 19
.TextArray(iIndex) = Rnd * 100
Next
End With
End Sub
Private Sub Command1_Click()
Form2.Show vbModal
End Sub
Code:Private Sub Form_Load()
Dim iField As Integer
With Form1.MSFlexGrid1
For iField = 0 To .Cols - 1
If iField Then Load txtField(iField)
txtField(iField).Move txtField(0).Left, txtField(0).Top + (iField * txtField(0).Height)
txtField(iField) = .TextMatrix(.Row, iField)
txtField(iField).Visible = True
Next
End With
End Sub
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
Hi Aaron,
When I put the code in as you've described above, I get error " Compile Error: Wrong number of arguments or invalid property assignmen." Any suggestions? Thanks.
Works fine when I cut and Paste it..
Did you Add a 2nd Form, with a Textbox on it called txtField with an Index Value of 0(Zero)?
If so, where are you getting the Error?
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
Allright, here's the situation. On form1 I click a row, then I click command2, the error then occurs on form2 at line: txtField(iDate).Move txtField(0).Left, txtField(0).Top(iDate * txtField(0).Height)....Top is highlighted...also, when I click on the button, flexgrid1 on form1 changes to several rows with random numbers!! Any suggestions?
Thanks,
Dave