I have a Flexgrid (VSFlexGrid 8) with 3 columns
grid name = Main_Window.form_seg_carrier_grid
Select | Name | ID
x | abc | 1
| cdf | 2
x | dfs | 3
The select column is defined as a Boolean data type, and is left up to the user to select which rows are true/false.
What I need is a way to take all rows that are true, and set the ID to an array.
Currently the only thing I can get is to show me which row is selected, or if it's true/false which is a 0 for false, and -1 for true.
The array can be built on a button click or on change.
EDIT 1
This is as far as I can get, this will fire off a msgbox ( quick way to test variables ) to show when it's being set to true
Private Sub form_seg_carrier_grid_Click()
Dim test As String
test = Main_Window.form_seg_carrier_grid.Value
If test = -1 Then
MsgBox test
End If
End Sub
Edit 2
I feel I'm close with something like this, just can't get it to do what I want..
Dim i As Integer
Dim test As String
For i = 0 To Main_Window.form_seg_carrier_grid.Rows - 1
If Main_Window.form_seg_carrier_grid.IsSelected(i) Then
If test <> vbNullString Then test = test & ", "
test = test & "'"
test = test & Main_Window.form_seg_carrier_grid.ValueMatrix(i, 1)
test = test & "'"
End If
Next i
I was able to accomplish this by adding a Boolean Column
0 is false, and -1 is true
Then I used this code to build an array that I can populate an SQL query with using the IN statement
(i, 3) designates what column I want the value to come from
Dim i As Integer
Dim test As String
For i = 0 To Main_Window.form_seg_carrier_grid.Rows - 1
If Main_Window.form_seg_carrier_grid.ValueMatrix(i, 0) = -1 Then
If test <> vbNullString Then test = test & ", "
test = test & "'"
test = test & Main_Window.form_seg_carrier_grid.ValueMatrix(i, 3)
test = test & "'"
End If
Next i
Output would be ( referencing original post )
'1','3'