How can I remove underline from the link label in compact framework? As there is no click event for label and textbox I have to use linklabel as its support click event.
Tried this solution but its not working showing error Error : Operator '!' cannot be applied to operand of type 'System.Drawing.FontStyle'
Any clue how to remove underline and change font color?
One easy way would be to inherit a user control from LinkLabel
and override OnPaint
. Therein use GDI+ to render the content of your LinkLabel. You'll still have all other functionality of the LinkLabel, except that the text won't have an underline, as you wish.
Something on the following lines:
class CustomLinkLabel : LinkLabel
{
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
//MyBase.OnPaint(e)
using (SolidBrush B = new SolidBrush(this.ForeColor))
{
e.Graphics.DrawString(this.Text, this.Font, B, e.ClipRectangle.X, e.ClipRectangle.Y);
}
}
}