I'm currently making an app in C# which make use of LinkLabels
. I have a function that add a new link for each element in a certain array. However, it happens that the array have more than 32 links, and when that happens, I receive an OverflowException:
System.OverflowException: Overflow error. at System.Drawing.StringFormat.SetMeasurableCharacterRanges(CharacterRange[] ranges) at System.Windows.Forms.LinkLabel.CreateStringFormat() at System.Windows.Forms.LinkLabel.EnsureRun(Graphics g) at System.Windows.Forms.LinkLabel.OnPaint(PaintEventArgs e) at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer) 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.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Is there a way to override the SetMeasurableCharacterRanges
function. So that it doesn't throw that error when having more than 32 character ranges?
Here is a sample of my code:
int LengthCounter = 0;
llbl.Links.Clear();
string[] props = AList.ToArray();
llbl.Text = string.Join(", ", props);
foreach (var Prop in props)
{
llbl.Links.Add(LengthCounter, Prop.Length, string.Format("{0}{1}", prefix, Sanitize(Prop)));
LengthCounter += Prop.Length + 2;
}