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
9 Answers, 1 is accepted
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

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
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

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
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

Tanya,
I am using the spreadsheet as a calendar with columns for each day. Employes defines their holydays in it. Within a dialog the user defines a date and than calls the calender. Now the spreadsheet appears and the column for the date should scroll into view.
Now my problem: I have a small range of columns (approx. 120 columns for 4 monthes), three fixed columns (via "FreezePanes(new CellIndex(4, 3))" and a large monitor (2540x1440 pixels).With
radSpreadSheet.ActiveWorksheetEditor.BringIntoView(new CellIndex(row, column));
selection.Select(new CellIndex(row, column));
I select the specific cell. The more the value of "column" approches 120 the more the selected and "intoview" column disappears to the left (until it is not visible). This effect becomes more drastic the smaller I make my program window.
Any help?
Thanks in advance
Marcus
I tried reproducing the behavior but so far I've been unsuccessful and I am most likely missing something. Do you think you could isolate this in a sample project you could sent to us? It would be of great help.
Regards,
Anna
Progress Telerik

Hi Anna,
Please run the attached project. You will see that the cell is selected but it is not in view (scroll a little bit to the right). While isolating this behavior I have seen that there is a difference between "jump to the cell" after loading and "jump to the cell" when spreadsheet is shown. If you press the button "Jump" on top (calling methode "doJump") everything is OK. At startup the "doJump"-methode is also called. But then this "bringintoview" is not working correctly.
While isolating the source for this post I have found an other strange behavior. Please press the button "New Sheet". You will see that suddenly there is a white gap between the first column an the rest to the right. A simple click on the horizontal scrollbar and the gap disapears?!
Regards
Marcus
Since this is a forum post, you won't be able to attach a project, but you will have to open a support ticket with us instead. I apologize for omitting to specify this in my previous reply.
I will be expecting your ticket with the attachment in order to investigate both issues you've reported, because so far I've been unable to reproduce the gap either. Thank you in advance.
Regards,
Anna
Progress Telerik