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

Can the Ctrl + A key combination only select used cells?

2 Answers 11 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
özer
Top achievements
Rank 1
Veteran
özer asked on 11 Mar 2021, 08:40 AM

Hi.

As is known, Ctrl + A selects all cells in the spreadsheet. Can we change this to only select cells that are full?

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 11 Mar 2021, 12:09 PM

Hi Ozer,

You need to create a custom input behavior and override the ProcessKeyDown method. Here is a sample implementation of this:

public partial class RadForm1 : Telerik.WinControls.UI.RadForm
{
    public RadForm1()
    {
        InitializeComponent();

        radSpreadsheet1.InputHandler = new MyInputBehavior(this.radSpreadsheet1.SpreadsheetElement);
    }
}

class MyInputBehavior : SpreadsheetInputBehavior
{
    RadSpreadsheetElement spreadsheet;

    public MyInputBehavior(RadSpreadsheetElement spreadsheet) : base (spreadsheet)
    {
        this.spreadsheet = spreadsheet;
    }

    public override void ProcessKeyDown(System.Windows.Forms.KeyEventArgs e)
    {
        if (e.Control && e.KeyCode == Keys.A)
        {
            CellRange usedRange = this.spreadsheet.ActiveWorksheet.UsedCellRange;
            spreadsheet.ActiveWorksheetEditor.Selection.Select(usedRange);
            return;
        }
        base.ProcessKeyDown(e);
    }
}

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

Regards,
Dimitar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
özer
Top achievements
Rank 1
Veteran
answered on 12 Mar 2021, 03:04 PM

Hi Dimitar,

Thanks for help. This was exactly the solution I was looking for. 

 
Tags
Spreadsheet
Asked by
özer
Top achievements
Rank 1
Veteran
Answers by
Dimitar
Telerik team
özer
Top achievements
Rank 1
Veteran
Share this question
or