[RESOLVED] Flexgrid search/Add to new flexgrid
Last part of my problem...I have this search function that searches through a flexgrid I have on my interface, and it works great...now what I need to do is bring each record that is found into a separate flexgrid with the same properties as the parent flexgrid, with just the records that were found...
any suggestions?
This is my search function:
VB Code:
Sub Search()
Dim target_name As String, sResult As String
Dim r As Integer, c As Integer, sResultArray() As String, sra As Integer
target_name = UCase$(InputBox("Letter", "Letter"))
If Len(target_name) = 0 Then Exit Sub
With grd
.Redraw = False
.FillStyle = flexFillRepeat
.Col = 1: .Row = 1
.ColSel = .Cols - 1
.RowSel = .Rows - 1
.CellBackColor = vbWhite
For r = 0 To .Rows - 1
For c = 1 To .Cols - 1
If .TextMatrix(r, c) Like target_name & "*" Then Exit For
Next c
If c < .Cols Then
For c = 1 To .Cols - 1
sResult = sResult & vbTab & .TextMatrix(r, c)
Next c
sResult = vbNullString
End If
Next r
.Col = 0: .Row = 0
.Redraw = True
End With
MsgBox "Finished!"
End Sub
Re: Flexgrid search/Add to new flexgrid
is the problem that you can't transfer the records? cos i told you how to do that before:
VB Code:
MSFlexGrid1.AddItem sResult
or is it that you need to create a duplicate of the FlexGrid (stylistically)?
Re: Flexgrid search/Add to new flexgrid
That only added the first column, and not any of the supplementary records...I'm thinking some sort of a split is necessary and a cycle through an array for each row...?
Re: Flexgrid search/Add to new flexgrid
I need to create a whole new flexgrid from the original flexgrid...with only the selected records being brought over...
Re: Flexgrid search/Add to new flexgrid
that only showed the first column, because you probably only had one column in the target grid. you'll need to set the right number of cols and rows and copy all the headers over.
it might be easier for you just to 'hide' the rows that didn't match:
VB Code:
Private Sub Command1_Click()
Dim target_name As String, sResult As String
Dim r As Integer, c As Integer
target_name = InputBox("Name", "Name")
If Len(target_name) = 0 Then Exit Sub
With MSFlexGrid1
.Redraw = False
.FillStyle = flexFillRepeat
.Col = 1: .Row = 1
.ColSel = .Cols - 1
.RowSel = .Rows - 1
.CellBackColor = vbWhite
.Col = 0: .Row = 0
.RowHeight(-1) = .RowHeight(0)
For r = 1 To .Rows - 1
For c = 1 To .Cols - 1
If .TextMatrix(r, c) Like target_name & "*" Then Exit For
Next c
If c = .Cols Then .RowHeight(r) = 0
Next r
.Redraw = True
End With
End Sub
Re: Flexgrid search/Add to new flexgrid
Works great, thanks!!! :thumb: