This is a migrated thread and some comments may be shown as answers.

On Sheet Change Scroll to A1

3 Answers 69 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
Iron
David asked on 03 Apr 2020, 02:01 AM
I would like to always freeze the first physical row and column whenever a sheet is selected. However the Freeze Panes method always indexes into whichever rows and columns are currently in the viewport, which might be anywhere on the sheet. How can I get the viewport to scroll to first physical row and column on sheet change?

3 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 03 Apr 2020, 10:37 AM

Hello David,

You can use the BringIntoView method for this, and you need to update the layout before calling this method:

public MainWindow()
{
    InitializeComponent();
    radSpreadsheet.ActiveSheetChanged += RadSpreadsheet_ActiveSheetChanged;       
}

private void RadSpreadsheet_ActiveSheetChanged(object sender, EventArgs e)
{
    RadWorksheetEditor worksheetEditor = radSpreadsheet.ActiveWorksheetEditor;
    worksheetEditor.FreezePanes(new CellIndex(1, 1));

    radSpreadsheet.UpdateLayout();
    worksheetEditor.BringIntoView(new CellIndex(1, 1));            
}

I hope this helps. Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
David
Top achievements
Rank 1
Iron
answered on 03 Apr 2020, 04:59 PM

It helped in so far as it pointed me in right direction.

However it has a fatal flaw in that toggling back and forth among same worksheets causes weird effects on return to a previous one.

Here is what I ended up with, which does work:

private async void Spreader_ActiveSheetChanged(object sender, EventArgs e)
        {
            if (Spreader.ActiveSheet != null)
            {
                var ed = Spreader.ActiveWorksheetEditor;
                ed.BringIntoView(new CellIndex(0, 0));
                Spreader.UpdateLayout();
                await Task.Delay(100);
                ed.UnfreezePanes();
                await Task.Delay(100);
                Spreader.UpdateLayout();
                ed.FreezePanes(new CellIndex(1, 1));
            }
        }

Not sure the Task Delays are really necessary, but does assure one action completes before the next starts.

David Pressman

0
Dimitar
Telerik team
answered on 06 Apr 2020, 07:48 AM

Hello David,

I am glad that you have found a solution for your case. Do not hesitate to contact us if you have other questions.

Regards,
Dimitar
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Spreadsheet
Asked by
David
Top achievements
Rank 1
Iron
Answers by
Dimitar
Telerik team
David
Top achievements
Rank 1
Iron
Share this question
or