0

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
Jeff Beagley
  • 945
  • 9
  • 19
  • Have you tried anything? Please show any attempt in the original post. SO generally is not a code for me site. – Scott Craner Dec 09 '15 at 19:22
  • Updated with the little I have, My post was generic because I have no idea where to go, hence coming to this site. – Jeff Beagley Dec 09 '15 at 19:25
  • You just want the ID number not the name in the array? – Scott Craner Dec 09 '15 at 19:27
  • @ScottCraner correct, the name is just a reference the user uses to make their selection since the ID is meaningless to them. I'll likely evne hide the ID once this is working. – Jeff Beagley Dec 09 '15 at 19:30
  • I was trying to take some code from another project I did that dumps the flex grid data into Excel using TextMatrix, so I thought I'd have to do something that would offset the column to get the rihgt value, then textmatrix to dump out only where it's true. – Jeff Beagley Dec 09 '15 at 19:33

1 Answers1

0

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'
Jeff Beagley
  • 945
  • 9
  • 19