mikepennst
asked on
MSFlexGrid: Want To Load arrays and variables
I'm real new to VB and I'm working on an application where I have a 2 Column MSFlexGrid. What I would like to do is load the 2nd Col with an array or a variable from a procedure. I can "hard load" data in the grid but don't understand why I can't bring in data from variables. The example Grid below is only 3 lines deep but in my procedure I need to display 101 lines. I like the way MSFlexGrid displays the data but am not sure this is the way to go. I've been stumped on this for a while and as I said earlier I'm just starting in VB.
Dim intLoadAddr00 as Integer
Dim intLoadAddr01 as Integer
Private Sub Form_Load()
' initialize grid
With AddrGrid
.Cols = 2
.Rows = 3
.ColWidth(0) = 500
.ColWidth(1) = 1000
.TextMatrix(0, 0) = "Addr"
.TextMatrix(1, 0) = "0"
.TextMatrix(2, 0) = "1"
.TextMatrix(0, 1) = "CODE"
.TextMatrix(1, 1) = intLoadAddr00
.TextMatrix(2, 1) = intLoadAddr01
End With
End Sub
Dim intLoadAddr00 as Integer
Dim intLoadAddr01 as Integer
Private Sub Form_Load()
' initialize grid
With AddrGrid
.Cols = 2
.Rows = 3
.ColWidth(0) = 500
.ColWidth(1) = 1000
.TextMatrix(0, 0) = "Addr"
.TextMatrix(1, 0) = "0"
.TextMatrix(2, 0) = "1"
.TextMatrix(0, 1) = "CODE"
.TextMatrix(1, 1) = intLoadAddr00
.TextMatrix(2, 1) = intLoadAddr01
End With
End Sub
In the MSFlexGrid you can set the .Row and the .Col properties and then simply set the .Text property to change the contents of the cell in question.
Check out this handy Flex Grid example ;-)
http://homepage.eircom.net/~carafa/VBSamples/VB5/MSFLEXGRID.zip
http://homepage.eircom.net/~carafa/VBSamples/VB5/MSFLEXGRID.zip
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
When using .TextMatrix property you can interprit it as an 2 dimentional array, Cols,Rows. Having that you can bring your procedure and populate it.
To load you Flexgrid.. try this (assuming you have VB6).. With your MSFlexgrid empty, then use the Additems method to populate your rows. In the array statement you can use variables or constants, whicever you require.
Dim varTable as variant
varTable = Array(strColumn1_Data, strColumn2_Data, intColumn3_Data, "etc")
MSFlexGrid1.AddItem Join(varTable, vbTab) ' Row 0 Space
Dim varTable as variant
varTable = Array(strColumn1_Data, strColumn2_Data, intColumn3_Data, "etc")
MSFlexGrid1.AddItem Join(varTable, vbTab) ' Row 0 Space