views:

153

answers:

4

Is there a control I can use to display a short message that contains minor html formatting (eg one or more links). I'd prefer not to use the WebBrowser control (suggested here) as it's a bit heavy for what I want, so any other suggestions welcome.

If a user does click a link from my message I want it to be opened in their default browser, not within my application.

I do use the infragistics controls so one of those would be fine but I don't see any that will do this.

+1  A: 

You can use the controls in this article on CodeProject or you can use them as an example for how to roll your own.

Dan Walker
A: 

If all you need is the link functionality you can use the LinkLabel control. Assuming that you have set the LinkLabel.Tag property to the url the following code will open the default browser and open the specified web page:

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
    Process.Start((string) ((sender as LinkLabel).Tag));
}
Jakob Christensen
A: 

I think the best solution in my case might be to use RichTextBox, which has a property DetectLinks and a LinkClicked event that tells you which link is clicked. I'll look into this further...

Rory
+1  A: 

I have implemented an HTML control for .NET which may do what you want: see http://www.modeltext.com/html for details.

The control can display HTML including links, and doesn't use a browser.

What happens when the user clicks on a link is up to you: the control generates an event, which can be handled by the application in which the control is embedded; so, your application would instantiate the control, fill it with HTML, install an event handler, and launch the browser when its event handler is told that the user has clicked on a link.

ChrisW