scroll the sfdatagrid to the bottom with variable height rows

Hi


I have a Windows Form with an sfDataGrid and I want to programatically scroll it to the bottom when it loads.


I've looked at the following article but I have an issue with it:

https://www.syncfusion.com/kb/9605/how-to-scroll-to-a-specific-record-programmatically-in-winforms-datagrid-sfdatagrid


The rows in my grid are of variable height and I'm using a QueryRowHeight event to set the row heights.

Here is my form when displayed:


If I then click my button which call:

sfDataGrid1.TableControl:ScrollRows:ScrollInView(sfDataGrid1.RowCount)

sfDataGrid1.TableControl.UpdateScrollBars()

 it doesn't scroll all the way to the bottom - there are still a couple of rows below the scroll point:


If I manually scroll it down you can see the other two lines in the table:



How do I get it to scroll all the way to the bottom?

Leigh


5 Replies

DM Dhanasekar Mohanraj Syncfusion Team April 22, 2022 05:02 PM UTC

Hi Leigh Anderson,


Currently, we are checking the feasibilities to achieve your requirement. We will check and update you further details on April 26, 2022. We appreciate your patience until then.


Regards,

Dhanasekar M.



DM Dhanasekar Mohanraj Syncfusion Team April 26, 2022 01:57 PM UTC

Hi Leigh Anderson,


With custom row heights using
QueryRowHeight event, the row heights change eventually based on the data whenever the rows coming to view, so that the size of the scroll bar will change based on current size of the rows. Since the scroll bar size vary periodically due to rows unknown size, we can’t scroll to particular scroll row positions programmatically and this is the default behavior.

Regards,
Dhanasekar M.



LA Leigh Anderson replied to Dhanasekar Mohanraj April 26, 2022 07:46 PM UTC

Hi

I just want to be able to scroll to the bottom - don't really need to scroll to a particular row.

Is there any way to do that?

Or even just the option to scroll to a particular number of pixels down?

Thanks

Leigh





DM Dhanasekar Mohanraj Syncfusion Team April 27, 2022 02:44 PM UTC

Hi Leigh Anderson,


Currently, we are checking the feasibilities to achieve your requirement. We will check and update you further details on April 29, 2022. We appreciate your patience and understanding.


Regards,

Dhanasekar M.



DM Dhanasekar Mohanraj Syncfusion Team April 29, 2022 01:56 PM UTC

Hi Leigh Anderson,

You can achieve your requirement by using LineHiddenChanged event like below,

this.sfDataGrid.TableControl.RowHeights.LineHiddenChanged += RowHeights_LineHiddenChanged;

private void RowHeights_LineHiddenChanged(object sender, HiddenRangeChangedEventArgs e)

{

    if(moveScrollToBottom)

    {

        this.sfDataGrid.TableControl.ScrollRows.ScrollBar.Value = this.sfDataGrid.TableControl.ScrollRows.ScrollBar.Maximum;

        this.sfDataGrid.TableControl.UpdateScrollBars();

    }

    moveScrollToBottom = false;

}


We have prepared the sample based on your scenario. Please check this and revert us if you need further assistance.

Regards,

Dhanasekar M.


Attachment: CS_5c384919.zip

Loader.
Up arrow icon