I have a requirement to set the tooltips on column headers for a databound RadGridView.
I have tried several ways to go about getting to the CellElement for the grid header row, the most promising of which was the GridView.MasterGridViewInfo.TableHeaderRow.Cells. However, the CellElement is always null for these GridViewCellInfo objects.
Can someone recommend a way to accomplish this?
Thanks in advance,
Dave
I have tried several ways to go about getting to the CellElement for the grid header row, the most promising of which was the GridView.MasterGridViewInfo.TableHeaderRow.Cells. However, the CellElement is always null for these GridViewCellInfo objects.
Can someone recommend a way to accomplish this?
Thanks in advance,
Dave
4 Answers, 1 is accepted
0
Hi David,
Thank you for writing.
You are correct. You could use GridView.MasterGridViewInfo.TableHeaderRow.Cells collection once the header row has been created. In the handler of the ColumnsChanged event you should check if CellElement is not null and then set ToolTipText property.
Please, review the code-block provided below:
I hope this helps. Do not hesitate to contact me again if you need additional assistance.
Best wishes,
Martin Vasilev
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Thank you for writing.
You are correct. You could use GridView.MasterGridViewInfo.TableHeaderRow.Cells collection once the header row has been created. In the handler of the ColumnsChanged event you should check if CellElement is not null and then set ToolTipText property.
Please, review the code-block provided below:
private void Form1_Load(object sender, EventArgs e) |
{ |
this.radGridView1.Columns.ColumnsChanged += new ColumnsCollectionChangedDelegate(Columns_ColumnsChanged); |
} |
void Columns_ColumnsChanged(GridViewColumn column, Telerik.WinControls.ItemsChangeOperation operation) |
{ |
foreach (GridViewCellInfo headerInfo in this.radGridView1.MasterGridViewInfo.TableHeaderRow.Cells) |
{ |
if (headerInfo.CellElement != null) |
{ |
headerInfo.CellElement.ToolTipText = headerInfo.CellElement.Text; |
} |
} |
} |
I hope this helps. Do not hesitate to contact me again if you need additional assistance.
Best wishes,
Martin Vasilev
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Chris
Top achievements
Rank 1
answered on 29 Mar 2012, 06:46 PM
Please update the code example so that it will work with the current version of the WinForms RadGridView control. The events and some of the properties are obsolete.
In my case, I am just trying to set a tooltip on a single column header.
Thanks!
Chris
In my case, I am just trying to set a tooltip on a single column header.
Thanks!
Chris
0
Accepted
Chris
Top achievements
Rank 1
answered on 29 Mar 2012, 07:08 PM
Kindly disregard my previous post. I figured out how to do it.
Sincerely,
Chris
private void grdMyGrid_ToolTipTextNeeded(object sender, Telerik.WinControls.ToolTipTextNeededEventArgs e)
{
if (sender is GridHeaderCellElement && ((GridHeaderCellElement)sender).Text == "Foo")
e.ToolTipText = "Bar";
}
Sincerely,
Chris
0
Ragan
Top achievements
Rank 1
answered on 23 Aug 2012, 09:28 PM
This is how I did it for a GridDataCellElement, in my case I needed to use data from the DataboundItem
void PayeeSummaryGrid_ToolTipTextNeeded(object sender, ToolTipTextNeededEventArgs e) { if (sender is GridDataCellElement) { Payee payee = PayeeSummaryGrid.Rows[((GridDataCellElement)sender).RowIndex].DataBoundItem as Payee; e.ToolTipText = "Payee: " + payee.PremiumPayableTo; } }