How to get RadSpreadsheet.ActiveWorksheet Cell focus border?

6 posts, 0 answers
  1. Sri
    Sri avatar
    6 posts
    Member since:
    Mar 2017

    Posted 21 Sep Link to this post

    Hi,

    How to get the cellborder focus rectangle (see attached) in the Telerik.Windows.Controls.RadSpreadsheet.ActiveWorksheet?

    I tried this but this doesn't give the desired output:

    View.sprSpecification.ActiveWorksheet
    .Cells[rowIndex, colIndex]
    .SetBorders(new CellBorders(new CellBorder(CellBorderStyle.Thin, ThemableColor.FromArgb(alfa: 255, red: 255, green: 0, blue: 0))));

     

    I'm using Telerik 2017.2.614.45.NoXaml

     

    Thanks,

    Sri

  2. Tanya
    Admin
    Tanya avatar
    577 posts

    Posted 25 Sep Link to this post

    Hi Sri,

    You can change the rectangle describing the selection using several properties exposed by the RadSpreadsheet class. More information about them you can find in the Customize Selection help topic.

    Hope this is helpful.

    Regards,
    Tanya
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  3. Sri
    Sri avatar
    6 posts
    Member since:
    Mar 2017

    Posted 04 Oct in reply to Tanya Link to this post

    Tanya,

    The Customize Selection example you're referred may work when user actually Selecting the cells on the Spreadsheet itself but my requirement is when user clicks on a row in RadGridView (not spreadsheet) then it should highlight/focus the cell (and possibly fill cell background) in the spreadsheet based on the RowIndex and ColumnIndex (these values are captured in RadGridView).

    Can you pls refer some examples on this?

    See attached for your understanding on what we are trying to do.

     

    Thanks

  4. Tanya
    Admin
    Tanya avatar
    577 posts

    Posted 09 Oct Link to this post

    Hello Sri,

    I am not sure I completely understand your requirements but will try to suggest you how you could change the borders and fill of a cell in RadSpreadsheet whose indices correspond to the ones of the selected cell in RadGridView:
    private void radGridView_CurrentCellChanged(object sender, GridViewCurrentCellChangedEventArgs e)
    {
        if (e.NewCell != null && e.OldCell!= null)
        {
            int oldColumnIndex = e.OldCell.Column.DisplayIndex;
            int oldRowIndex = this.radGridView.Items.IndexOf(e.OldCell.DataContext);
            this.radSpreadsheet.ActiveWorksheet.Cells[oldRowIndex, oldColumnIndex].ClearBorders();
            this.radSpreadsheet.ActiveWorksheet.Cells[oldRowIndex, oldColumnIndex].ClearFill();
     
     
            int columnIndex = e.NewCell.Column.DisplayIndex;
            int rowIndex = this.radGridView.Items.IndexOf(e.NewCell.DataContext);
     
            CellRange currentCellRange = new CellRange(rowIndex, columnIndex, rowIndex, columnIndex);
     
            Selection selection = this.radSpreadsheet.ActiveWorksheetEditor.Selection;
            selection.Select(currentCellRange);
     
            this.radSpreadsheet.Workbook.ActiveWorksheet.Cells[currentCellRange].SetBorders(new CellBorders(new CellBorder(CellBorderStyle.Thin, ThemableColor.FromArgb(alfa: 255, red: 255, green: 0, blue: 0))));
        }
    }

    Hope this will help you achieve the desired behavior.

    Regards,
    Tanya
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  5. Sri
    Sri avatar
    6 posts
    Member since:
    Mar 2017

    Posted 3 days and 20 hours ago in reply to Tanya Link to this post

    Tanya,

    I was able to make the border and fill color work but unable to bring the focus to the cell on the spreadsheet. I'm using this below line of code to bring the focus to the cell but it's not working.

    View.sprSpecification.ActiveWorksheetEditor.BringIntoView(new CellIndex(rowIndex, columnIndex));

    For a given valid rowIndex and columnIndex, I want the spreadsheet to scroll to that cell and show (focus) it on the screen. Any suggestions?

     

    Thanks,

    Sri

  6. Tanya
    Admin
    Tanya avatar
    577 posts

    Posted 1 day and 19 hours ago Link to this post

    Hello Sri,

    To move the focus and select the specified cell, you will need to invoke the Select method. When you have selected the active cell, you can also change its mode to Display or Active.
    this.radSpreadsheet.ActiveWorksheetEditor.BringIntoView(new CellIndex(rowIndex, columnIndex));
    this.radSpreadsheet.ActiveWorksheetEditor.Selection.Select(new CellIndex(rowIndex, columnIndex), true);
     
    this.radSpreadsheet.ActiveWorksheetEditor.Selection.ActiveCellMode = ActiveCellMode.Edit;

    You can find more information about the selection in the related documentation article.

    Regards,
    Tanya
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top