I need to implement a search for a grouping grid. it should search all columns for a given string regardless of grouping, then position the display to that record and expand if necessary (even if there are several groups).
so i looked at Record r = this.gridGroupingControl1.Table.Records.FindRecord("TEST1001") but it doesn''t compile, says doesn''t contain a definition for FindRecord.
this would be nice functionality to add to your examples library ;)
thanks in advance
if the grouping grid is sorted by that field you are trying to search, the following methods will give you very fast results:
int sp = this.gridGroupingControl1.Table.TopLevelGroup.Records.FindRecord("TEST");
However, since you mention that the table is not sorted by that record this is not a good option.
You do have two options available then:
1) If the underlying table is a searchable/indexed data source try to search the underlying source list index in the
underylying table. You can then convert that underlying source list index into the record index of the grid table.
int sourceIndex = underlyingDataSource.Find("Test000");
Record r = table.UnsortedRecords[sourceIndex];
// if you want to know the record index in grid table
int gridIndex = table.Records.IndexOf(r);
2) The slower method which will always works is to loop through the records manually:
int sourceIndex = 0;
FieldDescriptor fd = table.TableDescriptor.Fields["TestField");
foreach (Record r in table.UnsortedRecords)
if (fd.GetValue(r) == "Test"))
We have plans on adding support for searching and more indexing options to the grouping engine in future but we have no timeframe yet when that will happen.
AdministratorAugust 4, 2004 06:47 PM UTC
ok thanks that was helpful. SetCurrent makes it much easier than i thought.