• 0

Trouble with C# Windows Forms Control -- LinkLabel


Question

Hi,

I am having trouble using LinkLabel on Windows Form.

The scenario is like this:

I have a client listening and receiving links from a server.

The client updates its link on the UI with the links received.

How I did this is that I have an empty LinkLabel configured as the placeholder.

When I received links from the server, I do:

if (myLinkLabel.Links.Count !=0 ) //assuming that there will only be one link on this linklabel

{

myLinkLabel.RemoveAt(0);

}

myLinkLabel.Links.Add (0, strstr.Length, strstr); //strstr is the URL received form the server

However, I would get this exception:

System.ArgumentNullException: Value cannot be null.

Parameter name: region

at System.Drawing.Graphics.IntersectClip(Region region)

at System.Windows.Forms.LinkLabel.PaintLink(Graphics g, Link link, Brush foreBrush, Brush linkBrush, Boolean optimizeBackgroundRendering)

at System.Windows.Forms.LinkLabel.OnPaint(PaintEventArgs e)

at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)

at System.Windows.Forms.Control.WmPaint(Message& m)

at System.Windows.Forms.Control.WndProc(Message& m)

at System.Windows.Forms.Label.WndProc(Message& m)

at System.Windows.Forms.LinkLabel.WndProc(Message& msg)

at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)

at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)

at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)

at System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)

at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)

at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)

at System.Windows.Forms.Application.Run(Form mainForm)

My guess is that when it's trying to paint the Windows, there was no link found.

Can anyone tell me how I should go about solving this or is there a better way that I should do this?

thanks a bunch!!!!

:)

1 answer to this question

Recommended Posts

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.