Step 1:
2 MSFlexGrid controls (MSFlexGrid1, MSFlexGrid2)
2 Comboboxes (Combo1, Combo2)
Step 2:
Copy the following code (it is easily customisable and includes some values to let you see what it does):
Private Sub Combo1_Click()
'criteria:
'Students (Row 1)
'Teachers (Row 2)
'Average OP (Row 3)
'# of subjects (Row 4)
'schools:
'Somewhere High School
'Y High School
'7th Street High School
Select Case Combo1.Text
Case "Somewhere High School":
MSFlexGrid1.Row = 1 'row for # of students
MSFlexGrid1.Col = 1 'this is the column the specifics
'go into
MSFlexGrid1.Text = "796" 'how many students school has
MSFlexGrid1.Row = 2 'row for # of teachers
'you don't need to reset the column
MSFlexGrid1.Text = "53"
MSFlexGrid1.Row = 3 'Average OP
MSFlexGrid1.Text = "13"
MSFlexGrid1.Row = 4 '# of subjects offered
MSFlexGrid1.Text = "15"
Case "Y High School":
MSFlexGrid1.Row = 1
MSFlexGrid1.Col = 1
MSFlexGrid1.Text = "623"
MSFlexGrid1.Row = 2
MSFlexGrid1.Text = "87"
MSFlexGrid1.Row = 3
MSFlexGrid1.Text = "3"
MSFlexGrid1.Row = 4
MSFlexGrid1.Text = "38"
Case "7th Street High School":
MSFlexGrid1.Row = 1
MSFlexGrid1.Col = 1
MSFlexGrid1.Text = "1987"
MSFlexGrid1.Row = 2
MSFlexGrid1.Text = "129"
MSFlexGrid1.Row = 3
MSFlexGrid1.Text = "14"
MSFlexGrid1.Row = 4
MSFlexGrid1.Text = "27"
End Select
End Sub
Private Sub Combo2_Click()
'criteria:
'Students (Row 1)
'Teachers (Row 2)
'Average OP (Row 3)
'# of subjects (Row 4)
'schools:
'Somewhere High School
'Y High School
'7th Street High School
Select Case Combo2.Text
Case "Somewhere High School":
MSFlexGrid2.Row = 1 'row for # of students
MSFlexGrid2.Col = 1 'this is the column the specifics
'go into
MSFlexGrid2.Text = "796" 'how many students school has
MSFlexGrid2.Row = 2 'row for # of teachers
'you don't need to reset the column
MSFlexGrid2.Text = "53"
MSFlexGrid2.Row = 3 'Average OP
MSFlexGrid2.Text = "13"
MSFlexGrid2.Row = 4 '# of subjects offered
MSFlexGrid2.Text = "15"
Case "Y High School":
MSFlexGrid2.Row = 1
MSFlexGrid2.Col = 1
MSFlexGrid2.Text = "623"
MSFlexGrid2.Row = 2
MSFlexGrid2.Text = "87"
MSFlexGrid2.Row = 3
MSFlexGrid2.Text = "3"
MSFlexGrid2.Row = 4
MSFlexGrid2.Text = "38"
Case "7th Street High School":
MSFlexGrid2.Row = 1
MSFlexGrid2.Col = 1
MSFlexGrid2.Text = "1987"
MSFlexGrid2.Row = 2
MSFlexGrid2.Text = "129"
MSFlexGrid2.Row = 3
MSFlexGrid2.Text = "14"
MSFlexGrid2.Row = 4
MSFlexGrid2.Text = "27"
End Select
End Sub
Private Sub Form_Load()
MSFlexGrid1.Rows = 5
MSFlexGrid1.Cols = 2
MSFlexGrid2.Rows = 5
MSFlexGrid2.Cols = 2
MSFlexGrid1.Row = 0 'sets the row to the top row
MSFlexGrid1.Col = 0 'sets the column to the top column
MSFlexGrid1.Text = "Criteria" 'writes heading text
MSFlexGrid1.Col = 1 'sets column to left column
MSFlexGrid1.Text = "Result"
MSFlexGrid1.Col = 0
MSFlexGrid1.Row = 1 'heading for criteria
MSFlexGrid1.Text = "Students"
MSFlexGrid1.Row = 2
MSFlexGrid1.Text = "Teachers"
MSFlexGrid1.Row = 3
MSFlexGrid1.Text = "Average OP"
MSFlexGrid1.Row = 4
MSFlexGrid1.Text = "# subjects offered"
MSFlexGrid2.Row = 0 'sets the row to the top row
MSFlexGrid2.Col = 0 'sets the column to the top column
MSFlexGrid2.Text = "Criteria" 'writes heading text
MSFlexGrid2.Col = 1 'sets column to left column
MSFlexGrid2.Text = "Result"
MSFlexGrid2.Col = 0
MSFlexGrid2.Row = 1 'heading for criteria
MSFlexGrid2.Text = "Students"
MSFlexGrid2.Row = 2
MSFlexGrid2.Text = "Teachers"
MSFlexGrid2.Row = 3
MSFlexGrid2.Text = "Average OP"
MSFlexGrid2.Row = 4
MSFlexGrid2.Text = "# subjects offered"
'adds item to the combo boxes
Combo1.AddItem "Somewhere High School"
Combo1.AddItem "Y High School"
Combo1.AddItem "7th Street High School"
'gives same entries to other combo box
Combo2.AddItem "Somewhere High School"
Combo2.AddItem "Y High School"
Combo2.AddItem "7th Street High School"
'gives the columns width
MSFlexGrid1.ColWidth(0) = 1500
MSFlexGrid2.ColWidth(0) = 1500
End Sub
Main Topics
Browse All Topics





by: girish_itsPosted on 2003-02-11 at 02:29:49ID: 7924252
Hi,
,col)="str ing data for grid"
u can use the value of combo box by combo1.value and using 'if' condition u can check which data is to be shown in the grids.
Please tell me in detail about the source of data i.e. data is from database-recordset or from array.
u can use
dim mrow,mcol,i,j
for i=1 to msflexgrid1.row
for j=1 to msflexgird1.cols
msflexgrid1.textmatrix(row
next
next