We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Use of Records.FindRecord not working

Thread ID:

Created:

Updated:

Platform:

Replies:

68087 Sep 7,2007 05:11 PM UTC Sep 26,2007 06:47 AM UTC WinForms 8
loading
Tags: Grouping
Paul Sullivan
Asked On September 7, 2007 05:11 PM UTC

Hi,
I'm trying to find a row in a GGC based on a given value in a given column. On finding that row I then want to highlight it (i.e. as if it had been clicked so that the corresponding events then fire - so conditional formatting isn't what I want.)

I have used numerous snippets from various threads on this forum and seem to be able to successfully find the key field value i want but when I try and locate the record using
int index = GGC.treeList1.Table.TopLevelGroup.Records.FindRecord(keyFieldValue);
it ALWAYS returns 0. I'm a bit bemused that there isn't a method on the GGC such as FindRow([Column], [Value]) - maybe I have missed it??
I have attached one of your example apps, modified - the code executes when you click the "Find" button and the behaviour is the same on both your example grid and my attempted one.
Can you figure out what is going wrong/advise me a better way of doing what I want?
Thanks
Paul

SelfRelations.zip

J.Nagarajan [Syncfusion]
Replied On September 8, 2007 04:28 AM UTC

Hi Paul,

You can implement searching in gridgroupingcontrol by employing the GridFindReplaceDialogSink class and the GridFindReplaceDialog class. Please try the code below in a button click event handler.

GridCurrentCell cc = this.gridGroupingControl1.TableControl.CurrentCell;
if (cc.RowIndex == -1 || cc.ColIndex == -1)
this.gridGroupingControl1.TableControl.CurrentCell.Activate(1, 1);
else
this.gridGroupingControl1.TableControl.CurrentCell.Activate(cc.RowIndex, cc.ColIndex);

GridFindReplaceDialog frmdialog = GridFindReplaceDialog.Instance;
GridFindReplaceDialogSink frds = null;
frds = new GridFindReplaceDialogSink(this.gridGroupingControl1.TableControl);
frmdialog.StartPosition = FormStartPosition.CenterScreen;
frmdialog.SetState(frds, "", false);
frmdialog.ShowDialog();


Regards,
Nagaraj

J.Nagarajan [Syncfusion]
Replied On September 8, 2007 04:40 AM UTC

Hi Paul,

Also please take a look into this forum thread.

http://www.syncfusion.com/support/Forums/message.aspx?MessageID=42880

Regards,
Nagaraj

Paul Sullivan
Replied On September 10, 2007 08:50 AM UTC

Thanks, Nagarajan. Unfortunately I need to find a value which I am passed from another part of the app, so a pop-up dialogue box is not going to fulfil my requirement here.

Paul Sullivan
Replied On September 10, 2007 10:25 AM UTC

Nagarajan,
Also I am using the GridGroupingControl so am unable to use GridFindReplaceDialogSink as it requires GridControlBase

J.Nagarajan [Syncfusion]
Replied On September 11, 2007 08:03 PM UTC

Hi Paul,

If you just want to highlight a record based on a particular column please use the following code snippet

private Record FindRow(string column, string searchString)
{
Record searchRow = null;
foreach (Record rec in gridGroupingControl1.Table.FilteredRecords)
{
if (rec.GetValue(column).ToString() == searchString)
{
searchRow = rec;
gridGroupingControl1.Table.SelectedRecords.Clear();

gridGroupingControl1.Table.SelectedRecords.Add(rec);
rec.SetCurrent(column);
break;
}
}
return searchRow;
}

Please refer to the attached sample. In this sample please do the following

1. Run the sample.
2. Select a cell in Column1.
3. Type "Row1" in that particular cell.
4. Click on the "search" button, you can highlight that parcular Row.

You can download the sample from the following page.

http://websamples.syncfusion.com/samples/Grid.Windows/F68091/main.htm

Please refer to the sample and let me know if you have any questions.

Regards,
Nagaraj

Paul Sullivan
Replied On September 12, 2007 09:26 AM UTC

Hi Nagarajan,
Please run the demo app I atached to my post. The demo uses the Self-relation functionality of the GGC. When this functionality is being used the SetCurrent method you quoted does not work if the found row is a child row within the self-related grid. Please advise.
Thanks
Paul

Jeba S [Syncfusion]
Replied On September 26, 2007 06:45 AM UTC

Hi Paul,

If you want to set a record in the child table as current record, then you should expand its parent record and then set the corresponding record as current.

Please refer this code snippets:

Record parent = null;
Record rec = null;
private void button5_Click(object sender, EventArgs e)
{
string column = "Curve name";
foreach (Record r in gridGroupingControl2.Table.Records)
{
foreach (Record rc in r.NestedTables[0].ChildTable.Records)
{
if (rc.GetValue(column).ToString() == "CRD DS ERICSSON EUR")
{
parent = r;
rec = rc;
break;
}
}
}
parent.IsExpanded = true;
rec.SetCurrent();

}


Please refer the samplw which implements the above said feature:
http://websamples.syncfusion.com/samples/Grid.Windows/F68087_Sample/main.htm

Kindly let us know if you need any further assistance.

Best Regards,
Jeba.

Jeba S [Syncfusion]
Replied On September 26, 2007 06:47 AM UTC

Hi Paul,

If you want to set a record in the child table as current record, then you should expand its parent record and then set the corresponding record as current.

Please refer this code snippets:

Record parent = null;
Record rec = null;
private void button5_Click(object sender, EventArgs e)
{
string column = "Curve name";
foreach (Record r in gridGroupingControl2.Table.Records)
{
foreach (Record rc in r.NestedTables[0].ChildTable.Records)
{
if (rc.GetValue(column).ToString() == "CRD DS ERICSSON EUR")
{
parent = r;
rec = rc;
break;
}
}
}
parent.IsExpanded = true;
rec.SetCurrent();

}


Please refer the samplw which implements the above said feature:
http://websamples.syncfusion.com/samples/Grid.Windows/F68087_Sample/main.htm

Kindly let us know if you need any further assistance.

Best Regards,
Jeba.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;