New to Telerik UI for WinForms? Start a free 30-day trial
How to Show ToolTip for RadSpreadsheet Cell
Updated over 6 months ago
Environment
| Product Version | Product | Author |
|---|---|---|
| 2023.2.606 | RadSpreadsheet for WinForms | Dinko Krastev |
Description
For performance reasons, the cells in RadSpreadsheet are not separate elements and this prevents us from using the ToolTipTextNeeded event like in other controls.
Solution
To add a tooltip to a cell, we will need to subscribe to the MouseMove event of the ActiveWorksheetEditor. In the event handler, we can create our own instance of a RadToolTip and call its Show() method. Here is how you can get the cell under the mouse and show the tooltip:

C#
private RadWorksheetEditor editor = null;
public Form1()
{
InitializeComponent();
this.radSpreadsheet1.SpreadsheetElement.ActiveSheetEditorChanged += SpreadsheetElement_ActiveSheetEditorChanged;
}
private void SpreadsheetElement_ActiveSheetEditorChanged(object sender, EventArgs e)
{
if (this.editor != null)
this.editor.MouseMove -= Editor_MouseMove;
this.editor = this.radSpreadsheet1.ActiveWorksheetEditor;
if (this.editor != null)
this.editor.MouseMove += Editor_MouseMove;
}
private RadToolTip toolTip = new RadToolTip();
private string lastCellName = "";
private void Editor_MouseMove(object sender, MouseEventArgs e)
{
var activePresenter = this.radSpreadsheet1.ActiveWorksheetEditor.ActivePresenter as NormalWorksheetEditorPresenter;
if (activePresenter != null)
{
Point point = activePresenter.PointFromControl(e.Location);
CellIndex cellIndex = activePresenter.GetCellIndexFromViewPoint(point);
string cellName = NameConverter.ConvertCellIndexToName(cellIndex);
if (lastCellName != cellName)
{
toolTip.Show(cellName, Cursor.Position);
lastCellName = cellName;
}
if (cellIndex != null && cellIndex.RowIndex == 0)
{
toolTip.Hide();
}
}
}