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.
Unfortunately, activation email could not send to your email. Please try again.

Programmatically scrolling to a Row in GGC

Thread ID:

Created:

Updated:

Platform:

Replies:

28341 Apr 29,2005 09:44 AM May 2,2005 01:45 PM Windows Forms 8
loading
Tags: GridControl
vbaker
Asked On April 29, 2005 09:44 AM

How do I programmatically select, highlight and scroll into view a row in a GridGroupingControl? I have a combobox that uses the same datasource as the grid; when user selects an item in the combo box, I want the grid to scroll to that record. The user may have sorted the grid rows using any of its 5 columns. Previous threads have addressed similar questions, but noe of the suggestions seem to work for me. Using version 3.0.1.1. --Van Baker

Administrator [Syncfusion]
Replied On April 29, 2005 09:43 PM

Try code like this. //someRecord is the Record object you want to select and scroll in view this.gridGroupingControl1.Table.CurrentRecord = someRecord; someRecord.SetSelected(true);

vbaker
Replied On May 2, 2005 10:54 AM

To get the desired record based on user selection from the combobox, I am using this: int r = this.gridGroupingControl1.Table.PrimaryKeySortedRecords.FindRecord(this.combobox.SelectedValue); Syncfusion.Grouping.Record someRecord = gridGroupingControl1.Table.Records[r]; But, unless the grid is sorted by the column containing the primary key, the wrong record is returned. How can I get the correct record even if the user sorts the grid by a different column? --Van Baker >Try code like this. > >//someRecord is the Record object you want to select and scroll in view >this.gridGroupingControl1.Table.CurrentRecord = someRecord; >someRecord.SetSelected(true); >

Administrator [Syncfusion]
Replied On May 2, 2005 10:59 AM

If the combobox is unsorted, try using Syncfusion.Grouping.Record someRecord = this.gridGroupingControl1.Table.UnsortedRecords[this.combobox.SelectedValue];

Administrator [Syncfusion]
Replied On May 2, 2005 11:56 AM

Did you mean: this.gridGroupingControl1.Table.UnsortedRecords[this.combobox.SelectedIndex]; (Since SelectedValue is the primary key, not the item index)? Anyway, that works, except I had to add a call to this.gridGroupingControl1.TableControl.ScrollCellInView() in order to get the grid to scroll to the selected row if is not already visible. Also, sometimes, even though it highlights the correct row, it doesn''t always scroll it into view, even with the added ScrollCellInView() call. Finally, how do I get the grid to un-highlight a selection after a new selection is made programmatically? Thanks, Van Baker >If the combobox is unsorted, try using > >Syncfusion.Grouping.Record someRecord = >this.gridGroupingControl1.Table.UnsortedRecords[this.combobox.SelectedValue]; >

Administrator [Syncfusion]
Replied On May 2, 2005 12:14 PM

If you know the record whose selection you want to clear, you can use: someRecord.SetSelected(false); If you want to clear all records, try this.gridGroupingControl1.Table.SelectedRecords.Clear();

vbaker
Replied On May 2, 2005 12:54 PM

Clay, I do appreciate your assistance. This works well except for one minor problem. Sometimes the highlighted row does not quite scroll into view after ScrollCellInView() is called. If r is the index of the record I want to be visible, I am calling it as follows: this.gridGroupingControl1.TableControl.ScrollCellinView(r, this.gridGroupingControl1.TableControl.LeftColIndex); Usually, the selected row scrolls into view. Sometimes, however, even though the grid scrolls, it does not scroll quite enough, falling short of the selected row by about 3 rows. Is there a way to fix this? Thanks, Van Baker >If you know the record whose selection you want to clear, you can use: > >someRecord.SetSelected(false); > > >If you want to clear all records, try > >this.gridGroupingControl1.Table.SelectedRecords.Clear(); >

Administrator [Syncfusion]
Replied On May 2, 2005 01:09 PM

Just using code like this in a button handler scrolls the 17th record into view and selects it for me. Record someRecord = this.gridGroupingControl1.Table.UnsortedRecords[17]; this.gridGroupingControl1.Table.CurrentRecord = someRecord; someRecord.SetSelected(true); But if that does not work for you, try computing r in this manner to see if it works better. int r = this.gridGroupingControl1.Table.DisplayElements.IndexOf(someRecord); There is also a method, this.gridGroupingControl1.TableControl.ScrollInView, where you can pass the record and not have to get an index if that works better for you.

vbaker
Replied On May 2, 2005 01:45 PM

Thank You! ScrollInView(rec) did the trick. Odd how passing the index does not always work, but I''ll gladly stick with the way that does work. --Van Baker >Just using code like this in a button handler scrolls the 17th record into view and selects it for me. > >Record someRecord = this.gridGroupingControl1.Table.UnsortedRecords[17]; >this.gridGroupingControl1.Table.CurrentRecord = someRecord; >someRecord.SetSelected(true); > > >But if that does not work for you, try computing r in this manner to see if it works better. > >int r = this.gridGroupingControl1.Table.DisplayElements.IndexOf(someRecord); > > >There is also a method, this.gridGroupingControl1.TableControl.ScrollInView, where you can pass the record and not have to get an index if that works better for you. > >

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.

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.

;