This is a migrated thread and some comments may be shown as answers.

RadListBox Error when adding from another thread

4 Answers 163 Views
ComboBox and ListBox (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sasa Milovic
Top achievements
Rank 1
Sasa Milovic asked on 11 Jun 2007, 10:14 AM
Hi

I am adding items to listbox like this (from a background worker thread).

  dim d as New AddDelegate(AddressOf radListBox1.Items.Add)
  dim item as New RadListBoxItem
  item.Text = "some text"
  dim args() as Object = {item}
  radListBox1.Invoke(d, args)

However I sometimes get an error after some items are added (I think it
is also if an item is selected in the listbox and if I change hide and show the form). This is thrown on the main form. If tried using the BeginUpdate and EndUpdate method as well, but that doesn't seem to make a difference.

This is the message
    "Parameter is not valid."

Here is the stack trace

   at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
   at System.Drawing.Graphics.DrawImage(Image image, Int32 x, Int32 y, Int32 width, Int32 height)
   at System.Drawing.Graphics.DrawImage(Image image, Rectangle rect)
   at Telerik.WinControls.Paint.RadGdiGraphics.DrawBitmap(Image image, Int32 x, Int32 y, Double opacity)
   at Telerik.WinControls.Paint.RadGdiGraphics.DrawBitmap(Image image, Int32 x, Int32 y)
   at Telerik.WinControls.Primitives.FillElementPaintBuffer.ResetGraphics(IGraphics g, SizeF scale)
   at Telerik.WinControls.Primitives.FillPrimitive.PaintPrimitive(IGraphics g, Single angle, SizeF scale)
   at Telerik.WinControls.Primitives.BasePrimitive.PaintElement(IGraphics graphics, Single angle, SizeF scale)
   at Telerik.WinControls.RadElement.PaintElement(Graphics rawGraphics, IGraphics graphics, Single angle, SizeF scale, Region currentClip)
   at Telerik.WinControls.RadElement.Paint(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
   at Telerik.WinControls.RadElement.PaintOverride(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
   at Telerik.WinControls.RadElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
   at Telerik.WinControls.VisualElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
   at Telerik.WinControls.RadElement.Paint(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
   at Telerik.WinControls.RadItem.PaintOverride(IGraphics screenRadGraphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
   at Telerik.WinControls.RadElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
   at Telerik.WinControls.RadElement.Paint(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
   at Telerik.WinControls.RadElement.PaintOverride(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
   at Telerik.WinControls.RadElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
   at Telerik.WinControls.RadElement.Paint(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
   at Telerik.WinControls.RadElement.PaintOverride(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
   at Telerik.WinControls.RadElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
   at Telerik.WinControls.VisualElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
   at Telerik.WinControls.RadElement.Paint(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
   at Telerik.WinControls.RadItem.PaintOverride(IGraphics screenRadGraphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
   at Telerik.WinControls.RadElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
   at Telerik.WinControls.VisualElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
   at Telerik.WinControls.RadElement.Paint(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
   at Telerik.WinControls.RootRadElement.Paint(IGraphics graphics, Rectangle clipRectangle)
   at Telerik.WinControls.RadControl.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.ScrollableControl.WndProc(Message& m)
   at Telerik.WinControls.RadControl.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.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.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at Dcsa.WpAdmin2.UI.Startup.Main() in C:\_SourceCode\DCX (SA) Workplace\Workplace.Windows\Workplace.Admin.UI\Startup.vb:line 7
   at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

4 Answers, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 12 Jun 2007, 02:51 PM
Hi Sasa Milovic,

Thank you for your question.

We think that the problem is not related to the way you add items. Will it be possible to open a support ticket and send us a sample project so we could test it locally? Thanks in advance. We will review it as soon as we get the project.

 
Best wishes,
Georgi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Baris
Top achievements
Rank 1
answered on 18 Nov 2009, 06:49 PM
I hate to bump such an old thread, but I'm having a similar issue and would like to know if there ever was a resolution to this problem. The top of my stack:

Unhandled Exception -- Parameter is not valid

System.Drawing.StringFormat.get_Trimming()
Telerik.WinControls.Paint.RadGdiGraphics.DrawString
Telerik.WinControls.Paint.RadGdiGraphics.DrawString
Telerik.WinControls.UI.LightVisualElement.PaintText
Telerik.WinControls.UI.LightVisualElement.PaintContent

The exception box was unresponsive so I couldn't get the full stack, but I certainly don't make any calls to any drawing/gdi related functions. This app is a radgrid bound to a datatable. This seems to happen when the data in the datatable is being updated. During the update, the grid is in SuspendLayout() and the datatable is in BeginLoadData() mode. There is also a comboBox that is populated when it's expanded (depending on which tab is selected, each tab has a separate radgrid bound to a different datatable).

Another thing that looks odd is that the exception is claimed to be unhandled... All the code in my program's main() is in a try/catch block, I'm not sure how this is going unhandled.

Any help/insight would be hugely appreciated.

Thanks,
Baris


0
Baris
Top achievements
Rank 1
answered on 18 Nov 2009, 08:39 PM
So I found this other thread http://www.telerik.com/community/forums/aspnet/chart/33013-parameter-is-not-valid.aspx where the last post talks about the per process limit of GDI and User handles. I upped the number of GDI handles to the max of 64k, and User handles to the max of 18000, hoping this would resolve the issue -- since the symptom of running out of GDI handles is exactly what I'm seeing, where the GUI element that failed to draw becomes a "Red X" and the exception is thrown.

Unfortunately, we just saw this problem again, and with a different stack trace (the stack is sort of random when this happens). It is below, just in case it provides more details.

See the end of this message for details on invoking

just-in-time (JIT) debugging instead of this dialog box.

 

************** Exception Text **************

System.NullReferenceException: Object reference not set to an instance of an object.

   at Telerik.WinControls.UI.GridCellElement.PaintElement(IGraphics graphics, Single angle, SizeF scale)

   at Telerik.WinControls.RadElement.PaintElement(Graphics rawGraphics, IGraphics graphics, Single angle, SizeF scale, Region currentClip)

   at Telerik.WinControls.RadElement.Paint(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)

   at Telerik.WinControls.RadItem.PaintOverride(IGraphics screenRadGraphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)

   at Telerik.WinControls.RadElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)

   at Telerik.WinControls.VisualElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)

   at Telerik.WinControls.UI.GridRowElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)

   at Telerik.WinControls.RadElement.Paint(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)

   at Telerik.WinControls.RadItem.PaintOverride(IGraphics screenRadGraphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)

   at Telerik.WinControls.RadElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)

   at Telerik.WinControls.VisualElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)

   at Telerik.WinControls.RadElement.Paint(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)

   at Telerik.WinControls.RadItem.PaintOverride(IGraphics screenRadGraphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)

   at Telerik.WinControls.RadElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)

   at Telerik.WinControls.VisualElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)

   at Telerik.WinControls.RadElement.Paint(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)

   at Telerik.WinControls.RadItem.PaintOverride(IGraphics screenRadGraphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)

   at Telerik.WinControls.RadElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)

   at Telerik.WinControls.VisualElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)

   at Telerik.WinControls.RadElement.Paint(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)

   at Telerik.WinControls.RadItem.PaintOverride(IGraphics screenRadGraphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)

   at Telerik.WinControls.RootRadElement.Paint(IGraphics graphics, Rectangle clipRectangle)

   at Telerik.WinControls.RadControl.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.ScrollableControl.WndProc(Message& m)

   at Telerik.WinControls.RadControl.WndProc(Message& m)

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

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

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


0
Victor
Telerik team
answered on 23 Nov 2009, 09:05 AM
Hi Baris,

Thank you for writing. I kindly ask you to submit a new support ticket for this issue since the title says it is about RadListBox. Also please attach a sample project which demonstrates the crash as we are unable to determine what causes it with the provided information. 
If you can not submit a sample application please provide detailed steps on what needs to be done so that we can reproduce the exception. Also, in order to handle such an exception, you have to subscribe to the ThreadException event of the Application class. Thank you for your understanding.

Greetings,
Victor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
ComboBox and ListBox (obsolete as of Q2 2010)
Asked by
Sasa Milovic
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Baris
Top achievements
Rank 1
Victor
Telerik team
Share this question
or