Hi Donald,
Thank you for the question.
Our Html-like feature does not support this functionality out of the box and you can detect the link that the user have pressed after the press action.
Please refer to the code snippet which demonstrates how to detect the pressed link:
this.radLabel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.radLabel1_MouseDown);
private FormattedText IsMouseOverBlock(FormattedTextBlock textBlock, MouseEventArgs e)
{
Point elementAtPoint = this.radLabel1.LabelElement.PointFromControl(e.Location);
int linesCount = textBlock.Lines.Count;
for (int i = 0; i < linesCount; ++i)
{
TextLine textLine = textBlock.Lines[i];
int textLineCount = textLine.List.Count;
for (int j = 0; j < textLineCount; ++j)
{
FormattedText formattedText = textLine.List[j];
if (!string.IsNullOrEmpty(formattedText.Link) && formattedText.DrawingRectangle.Contains(elementAtPoint))
{
return formattedText;//found link under mouse
}
}
}
return null;//notfound
}
private void radLabel1_MouseDown(object sender, MouseEventArgs e)
{
FieldInfo pi = this.radLabel1.LabelElement.Children[2].Children[1].GetType().GetField("textPrimitiveImpl", BindingFlags.Instance | BindingFlags.SetProperty |BindingFlags.NonPublic);
TextPrimitiveHtmlImpl text = (TextPrimitiveHtmlImpl)pi.GetValue(this.radLabel13.LabelElement.Children[2].Children[1]);
FormattedTextBlock textBlock = text.TextBlock;
FormattedText clickedLink = IsMouseOverBlock(textBlock, e);
if (clickedLink != null)
{
MessageBox.Show(clickedLink.Text + " pressed");
}
}
I hope this helps.
Regards,
Peter
the Telerik team
Q1’11 SP1 of RadControls for WinForms is available for
download; also available is the Q2'11
Roadmap for Telerik Windows Forms controls.