Hi Team,
I have changed the backcolor of the tooltip with below code but it is not working,
RadToolTip toolTip =
new
RadToolTip();
toolTip.IsBalloon =
true
;
toolTip.BackColor = Color.LightSkyBlue;
toolTip.SetToolTip(
this
.button1,
"Telerik test"
);
6 Answers, 1 is accepted
Thank you for writing.
RadToolTip is a derivative of the MS ToolTip. The following StackOverflow thread demonstrates a sample approach how to customize the BackColor: http://stackoverflow.com/questions/12990757/change-winform-tooltip-backcolor
Here is a sample code snippet:
public
RadForm1()
{
InitializeComponent();
this
.radButton1.ShowItemToolTips =
true
;
this
.radButton1.ToolTipTextNeeded += radButton1_ToolTipTextNeeded;
}
private
void
radButton1_ToolTipTextNeeded(
object
sender, ToolTipTextNeededEventArgs e)
{
e.ToolTip.BackColor = Color.Yellow;
e.ToolTip.ForeColor = Color.Red;
e.ToolTipText =
"Telerik button"
;
e.ToolTip.OwnerDraw =
true
;
e.ToolTip.Draw += ToolTip_Draw;
}
private
void
ToolTip_Draw(
object
sender, DrawToolTipEventArgs e)
{
ToolTip toolTip = sender
as
ToolTip;
e.Graphics.FillRectangle(
new
SolidBrush(toolTip.BackColor), e.Bounds);
e.DrawBorder();
e.DrawText(TextFormatFlags.Left);
}
I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
Telerik by Progress
hi, Dess | Tech Support Engineer, Sr.
It works with your method. but, I want to change the pop-up position too, what should I do?
Thank you very much
Hello,
If you want to change the position of the tooltip you can use one of the Show method overrides. More information is available here: https://docs.telerik.com/devtools/winforms/telerik-presentation-framework/tooltips-and-screentips/radtooltip#radtooltip
private void radButton1_ToolTipTextNeeded(object sender, ToolTipTextNeededEventArgs e)
{
RadToolTip newToolTip = new RadToolTip();
newToolTip.BackColor = Color.Yellow;
newToolTip.ForeColor = Color.Red;
newToolTip.OwnerDraw = true;
newToolTip.InitialDelay = 2000;
newToolTip.Show("Telerik button", new Point(200, 200));
e.ToolTipText = "";
}
Do not hesitate to contact us if you have other questions.
Regards,
Nadya
Progress Telerik
Hello, Dess | Tech Support Engineer, Sr.
Thanks for your reply, why didn't it autoclose?
I didn't find a way.
Hello, Dess | Tech Support Engineer, Sr.
I did this with the control's MouseLeave event, thanks for your help.
Usually, the tool-tip is displayed below the control. The easiest way to manipulate its position is to specify the ToolTipTextNeededEventArgs.Offset property instead of creating a brand new instance of RadToolTip and showing it programamtically. Thus, you are not expected to experience any issues with hiding the tool-tip which is shown by default.
private void radButton1_ToolTipTextNeeded(object sender, ToolTipTextNeededEventArgs e)
{
e.Offset = new System.Drawing.Size(20,20);
e.ToolTipText = "Telerik button";
}
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik