Telerik blogs

I promised that I will continue the "tooltips" series by demonstrating a "HOWTO" approach with our RadMultiColumnComboBox component.

So what is the big difference with RadComboBox?

What is really different is that RadGridView uses temporary elements to render grid cells, that are recycled every time you change something inside the screen estate of the RadGridView (say like scrolling). This means that setting the TooltipText properties of the cells in design time or through the API won't work.

The solution

That leaves us with the second approach only: to use the ToolTipTextNeeded event to get the job done.  Here is a small example of how to do it.

1. First you have to bind the RadMultiColumnComboBox component to a valid data source and a appropriate data member - in our case this is the Cars table from a database we use internally for testing.

Setting the Data Source in design time 

2. Then you wire the ToolTipTextNeeded event to an eventhandler, the best place is the Load evethandler of the form.

private void TestComboBox1_Load(object sender, EventArgs e)
 // TODO: This line of code loads data into the 'nwindDataSet.Cars' table. You can move, or remove it, as needed.
 this.radMultiColumnComboBox1.MultiColumnComboBoxElement.EditorControl.ToolTipTextNeeded +=
 new Telerik.WinControls.ToolTipTextNeededEventHandler(EditorControl_ToolTipTextNeeded);

3. Inside the eventhandler you place your custom logic responsible for the tooltips content (in this case the row index, the column index, and the data type of the cell are shown).

void EditorControl_ToolTipTextNeeded(object sender, Telerik.WinControls.ToolTipTextNeededEventArgs e)
 GridDataCellElement element = sender as GridDataCellElement;
 if (element == null)
 string message = "This cell is positioned at row:{0}, column:{1} and its data type is {2}";
 GridViewDataColumn column = element.ColumnInfo as GridViewDataColumn;
 if (column != null)
        e.ToolTipText =
 string.Format(message, element.RowIndex, element.ColumnIndex, column.DataType.ToString());

About the Author

Nikolay Diyanov

Diyanov is the Product Manager of the Native Mobile UI division at Progress. Delivering outstanding solutions that make developers' lives easier is his passion and the biggest reward in his work. In his spare time, Nikolay enjoys travelling around the world, hiking, sun-bathing and kite-surfing.

Find him on Twitter @n_diyanov or on LinkedIn.


Comments are disabled in preview mode.