The text I'm displaying in the GridView is often much too long to fit in columns.
How do I display flyover- or ToolTip text as I move the mouse over the grid?
I don't see a HitTest property.
There are a lot of events, like
"ToolTipTextNeeded", "MouseMove", "CursorChanged" but I don't know how to use the "e" argument from those events to retrieve the cell content the cursor is over.
I'm sure there is a most efficient way of doing this.
Finn
How do I display flyover- or ToolTip text as I move the mouse over the grid?
I don't see a HitTest property.
There are a lot of events, like
"ToolTipTextNeeded", "MouseMove", "CursorChanged" but I don't know how to use the "e" argument from those events to retrieve the cell content the cursor is over.
I'm sure there is a most efficient way of doing this.
Finn
8 Answers, 1 is accepted
0
Hi Finn,
Every RadItem descendant has a TooltipText property. You can set this string property in order to display tooltips that you have set explicitly.
Other than that you can use the ToolTipTextNeeded event to display tool tips based on dynamic conditions.
You can also check out the "Displaying Tooltips" example for RadGridView in our Quick-Start Framework application. The example demonstrates the usage the event arguments and display tool tips inside a RadGridView.
Regards,
Dimitar Kapitanov
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Every RadItem descendant has a TooltipText property. You can set this string property in order to display tooltips that you have set explicitly.
Other than that you can use the ToolTipTextNeeded event to display tool tips based on dynamic conditions.
You can also check out the "Displaying Tooltips" example for RadGridView in our Quick-Start Framework application. The example demonstrates the usage the event arguments and display tool tips inside a RadGridView.
Regards,
Dimitar Kapitanov
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Finn
Top achievements
Rank 1
answered on 08 Jul 2008, 03:06 AM
OK, I looked for the Quick-Start Framework application and downloaded the 045389_QSF.zip file. Is that the one? I didn't see any "Displaying Tooltips" example in there.
This is what I need:
Which event (mousemove?) should I use?
How to I use the arguments from that event to get the content of the cell the mouse is on top of?
Finn
This is what I need:
Which event (mousemove?) should I use?
How to I use the arguments from that event to get the content of the cell the mouse is on top of?
Finn
0
Hi Finn,
The Quick-Start Framework application comes in the installation pakcage of our controls. So, when you have the controls installed on your machine, you will be able to observe the application as well. The location where you can find it is: START >> Programs >> Telerik >> RadControls for WinForms [version] >> RadControls for WinForms Examples.
The application which you have downloaded is just the shell application of the examples. It is published in our Code Library section due to numerous inquiries from our customers.
As demonstrated in the real Quick-Start Framework application (section RadGridView >> Displaying Tooltips), the event which you need is the ToolTipTextNeeded. The sender is a CellElement, so you can easiliy set the the text of the ToolTip to be the Value of the CellElement:
If you have additional questions, feel free to contact me.
Regards,
Nikolay
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
The Quick-Start Framework application comes in the installation pakcage of our controls. So, when you have the controls installed on your machine, you will be able to observe the application as well. The location where you can find it is: START >> Programs >> Telerik >> RadControls for WinForms [version] >> RadControls for WinForms Examples.
The application which you have downloaded is just the shell application of the examples. It is published in our Code Library section due to numerous inquiries from our customers.
As demonstrated in the real Quick-Start Framework application (section RadGridView >> Displaying Tooltips), the event which you need is the ToolTipTextNeeded. The sender is a CellElement, so you can easiliy set the the text of the ToolTip to be the Value of the CellElement:
private void radGridView1_ToolTipTextNeeded(object sender, ToolTipTextNeededEventArgs e) |
{ |
GridDataCellElement dataCell = sender as GridDataCellElement; |
if (dataCell != null) |
{ |
e.ToolTipText = dataCell.Value.ToString(); |
} |
} |
If you have additional questions, feel free to contact me.
Regards,
Nikolay
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Finn
Top achievements
Rank 1
answered on 15 Jul 2008, 06:26 PM
Thank you very much. I managed to translate that to VB:
Private Sub RadGridView1_ToolTipTextNeeded(ByVal sender As Object, ByVal e As Telerik.WinControls.ToolTipTextNeededEventArgs) Handles rgvWorkspaces.ToolTipTextNeeded
Dim datacell As Telerik.WinControls.UI.GridDataCellElement = sender
If Not datacell Is Nothing Then
e.ToolTipText = datacell.Value.ToString()
Else
e.ToolTipText =
"Default tool tip text goes here"
End If
End Sub
0
Curtis
Top achievements
Rank 2
answered on 24 Mar 2011, 09:37 PM
Can i set the tooltipText to be values of other columns in the same row???
0
Richard Slade
Top achievements
Rank 2
answered on 24 Mar 2011, 10:30 PM
Hello,
Yes, you can do this by just referencing the RowInfo, and then navigating to the cell from which you want the text. E.g.
Hope that helps
Richard
Yes, you can do this by just referencing the RowInfo, and then navigating to the cell from which you want the text. E.g.
private
void
radGridView1_ToolTipTextNeeded(
object
sender, ToolTipTextNeededEventArgs e)
{
GridDataCellElement dataCell = sender
as
GridDataCellElement;
if
(dataCell !=
null
)
{
if
(dataCell.RowInfo.Cells[
"ColumnName"
].Value !=
null
)
{ e.ToolTipText = dataCell.RowInfo.Cells[
"ColumnName"
].Value.ToString(); }
}
}
Hope that helps
Richard
0
Asif
Top achievements
Rank 1
answered on 19 Mar 2015, 01:15 PM
This works for me as well, but there are two things
1) I want to display the tooltip only when the text isn't not fully visible
2) I want to display the tooltip for column header cells as well if the column name is large and doesn't fit into current width of the column. How to do it.
1) I want to display the tooltip only when the text isn't not fully visible
2) I want to display the tooltip for column header cells as well if the column name is large and doesn't fit into current width of the column. How to do it.
0
Hi Asif,
Thank you for writing.
This type of behavior is not provided out of the box. However you can easily achieve the desired behavior by subscribing to the ToolTipTextNeeded event and in the handler measure the string content of the cell. Then, if the content does not fit you could show the tool tip. Please see my code snippet below:
I am also sending you a gif file of the result on my end.
I hope this information helps. Should you have further questions please do not hesitate to write back.
Regards,
Hristo Merdjanov
Telerik
Thank you for writing.
This type of behavior is not provided out of the box. However you can easily achieve the desired behavior by subscribing to the ToolTipTextNeeded event and in the handler measure the string content of the cell. Then, if the content does not fit you could show the tool tip. Please see my code snippet below:
private
void
radGridView1_ToolTipTextNeeded(
object
sender, Telerik.WinControls.ToolTipTextNeededEventArgs e)
{
GridDataCellElement dataCell = sender
as
GridDataCellElement;
if
(dataCell !=
null
&& dataCell.Value !=
null
)
{
SizeF dataCellValueSize =
this
.GetCellContentSize(dataCell.Value.ToString(),
this
.radGridView1.Font);
if
(dataCellValueSize.Width > dataCell.ColumnInfo.Width)
{
e.ToolTipText = dataCell.Value.ToString();
}
else
{
e.ToolTipText =
""
;
}
}
GridHeaderCellElement headerCell = sender
as
GridHeaderCellElement;
if
(headerCell !=
null
)
{
SizeF headerCelllValueSize = radGridView1.CreateGraphics().MeasureString(headerCell.Value.ToString(), radGridView1.Font);
if
(headerCelllValueSize.Width > headerCell.ColumnInfo.Width)
{
e.ToolTipText = headerCell.Text;
}
else
{
e.ToolTipText =
""
;
}
}
}
private
SizeF GetCellContentSize(
string
text, Font font)
{
return
this
.radGridView1.CreateGraphics().MeasureString(text, font);
}
I am also sending you a gif file of the result on my end.
I hope this information helps. Should you have further questions please do not hesitate to write back.
Regards,
Hristo Merdjanov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.