VScrollBar auto-scroll to bottom of GridGroupingControl

I have a GridGroupingControl g which is bound to a DataTable.

If g is scrolled to the bottom when a new row is added, I want it to stay scrolled to the bottom. Something like this:



bool wasScrolledToBottom = g.TableControl.VScrollBar.Value == g.TableControl.VScrollBar.Maximum;

// now add a row the the datatable

if (wasScrolledToBottom)
g.TableControl.VScrollBar.Value = g.TableControl.VScrollBar.Maximum;



However, it seems that it is never true that g.TableControl.VScrollBar.Value == g.TableControl.VScrollBar.Maximum.

How can I get this behavior?

1 Reply

JJ Jisha Joy Syncfusion Team June 23, 2010 08:53 AM UTC


Hi James,

You could use the TableModel.ScrollCellInView method of GridgroupingControl to stay scrolled to the desired row. See the code:

//now add a row to the datatable

this.gridGroupingControl1.TableModel.ScrollCellInView(GridRangeInfo.Row(this.gridGroupingControl1.TableModel.RowCount), GridScrollCurrentCellReason.Any);

Regards,
Jisha

Loader.
Up arrow icon