One minute
Another little code snippet
Whenever I have to code a “real” project, I end up building a bunch of components to deal with anything that seems likely to reoccur. Sometimes the class or Windows Forms control I’ve created never gets used again, but often I end up using them in a whole bunch of additional apps. Anyway, I think I’ll post some of these little bits of development work to my blog when it seems useful enough, and perhaps other developers will be able to find this code when they are looking for some help.
This particular piece of code is pretty simple; it is just a small extension to the LinkLabel class to allow it to handle launching the appropriate link when clicked.
</o:p>
public class ClickableLinkLabel : LinkLabel
{
private string m_URL = "about:blank";
public ClickableLinkLabel()
{
}
protected override void OnLinkClicked
(LinkLabelLinkClickedEventArgs e)
{
ProcessStartInfo psi
= new System.Diagnostics.ProcessStartInfo(m_URL);
psi.UseShellExecute = true;
System.Diagnostics.Process.Start(psi);
base.OnLinkClicked(e);
}
///
/// Represents the link to be navigated
/// to when the label is clicked
///
public string URL
{
get
{
return m_URL;
}
set
{
m_URL = value;
}
}
}
Thoughts on this post? Feel free to reach out on Bluesky!