PDA

Click to See Complete Forum and Search --> : MS Flexgrid question


mecca
Jan 26th, 2000, 03:28 AM
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?

netSurfer
Jan 26th, 2000, 03:31 AM
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.

Aaron Young
Jan 26th, 2000, 03:39 AM
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..
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
In Form2..
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
aarony@redwingsoftware.com
ajyoung@pressenter.com

mecca
Jan 27th, 2000, 06:42 AM
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.

Aaron Young
Jan 27th, 2000, 06:48 AM
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
aarony@redwingsoftware.com
ajyoung@pressenter.com

mecca
Jan 27th, 2000, 09:41 PM
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