PDA

Click to See Complete Forum and Search --> : Flexgrid


Helen
Jan 4th, 2000, 05:29 PM
I have a search facility on a flexgrid. When the search results are returned, the coding I have shows the search text highlighted within the flexgrid. However, the rows that do not contain the search text are also shown. How can I show only those rows which contain the search text?

Clunietp
Jan 5th, 2000, 01:53 AM
I don't believe that the flexgrid has a FILTER property.....I suppose you could follow this pseudocode:

DO UNTIL (LAST ROW IN GRID)
IF CONDITION = FALSE THEN (REMOVE ROW)
LOOP

Just my 2 cents

Gerald
Jan 5th, 2000, 07:20 AM
You can set your flexgrid's datasource property to an ADO recordset. Then all you need to do is change the recordset's filter property and your flexgrid will automatically show the results. For an example, add a hierarchical flexgrid and a couple of command buttons to a form and try the following code.


Dim cn As New ADODB.Connection
Dim rs As ADODB.Recordset

Private Sub Command1_Click()
rs.Filter = "companyname LIKE 'g%'"
End Sub

Private Sub Command2_Click()
rs.Filter = adFilterNone
End Sub

Private Sub Form_Load()
cn.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.3.51;Data Source=northwind.mdb"
cn.CursorLocation = adUseClient
cn.Open

Set rs = cn.Execute("SELECT * FROM customers")
Set MSHFlexGrid1.DataSource = rs

End Sub

Clunietp
Jan 5th, 2000, 12:26 PM
Good thinkin' Gerald, I forgot you can bind to the flexgrid.... :)