Wingrid marked Cross if you are not using screen for sometime
As the above screen shot displayed..above...my all grid marked cross ...automatically ...any idea ..why this happens ..?
Hi,
The big red X in an control means that an exception occurred in that control's OnPaint method.
This can be caused by a bug in the control, but more often it's the result of improper use of multiple threads in an application which causes the control to get out of synch with it's data source.
Is your application using threading?
Hi Mike,
We have 6 grids in this form.We are loading some user controls(containing images,progress bar) etc to the grid cells.We are also loading some image boxes (created dynamically) to the cells.When the initial load happens everything is going smoothly.
We have an option in this form for refreshing the grids as per the time interval set by user.For that we are using a timer.The refresh process also is happening properly for a couple of times.After that ,during 5th or 6th refresh, we are getting this problem.Once this happens,the application hangs but the timer tick event is not stopping.
Do you have any suggetions or solutions for this X mark issue?
What kind of Timer are you using?
If you are using a System.Windows.Forms.Timer, then it should work okay, as this timer is synchronous and works on the UI Thread.
If you are using System.Timer, then this operates on a separate thread and will certainly cause problems like the one you are getting here.
Created a sample application .Please check on my code. To re produce this error u can run the app and keep the application open for 30 min …
Sample Code
--------------------
Please check on it. Let me know any solution you have..To resolve it
Thanks
Prasant Rout
Hi Mike ,Forget to post the exception ,which i m getting from application
System.OutOfMemoryException was unhandled
Message="Exception of type 'System.OutOfMemoryException' was thrown."
Source="mscorlib"
StackTrace:
at System.Security.Permissions.SecurityPermission.Copy()
at System.Security.FrameSecurityDescriptor.CreateSingletonSet(IPermission perm)
at System.Security.FrameSecurityDescriptor.SetAssert(IPermission perm)
at System.Security.CodeAccessSecurityEngine.Assert(CodeAccessPermission cap, StackCrawlMark& stackMark)
at System.Security.CodeAccessPermission.Assert()
at System.Windows.Forms.NativeWindow.ReleaseHandle(Boolean handleValid)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.IntDestroyWindow(HandleRef hWnd)
at System.Windows.Forms.UnsafeNativeMethods.DestroyWindow(HandleRef hWnd)
at System.Windows.Forms.NativeWindow.DestroyHandle()
at System.Windows.Forms.Control.DestroyHandle()
at System.Windows.Forms.Control.Dispose(Boolean disposing)
at System.Windows.Forms.ContainerControl.Dispose(Boolean disposing)
at System.Windows.Forms.Form.Dispose(Boolean disposing)
at Sample_app.Form1.Dispose(Boolean disposing) in C:\Documents and Settings\jitheshk\Desktop\7167.Sample_app\Form1.Designer.cs:line 20
at System.ComponentModel.Component.Dispose()
at System.Windows.Forms.Form.WmClose(Message& m)
at System.Windows.Forms.Form.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.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.Form.DefWndProc(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmSysCommand(Message& m)
at System.Windows.Forms.Form.WmNcButtonDown(Message& m)
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 Sample_app.Program.Main() in C:\Documents and Settings\jitheshk\Desktop\7167.Sample_app\Program.cs:line 18
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()
InnerException:
Hello,
I am just checking about the progress of this issue
I believe we answer your question. Let me know if you have any further questions or I may close this case.
Thank you contacting us for this question.
Hi Prasant,
Obviously, I don't know all of the requirements of your application, but I still don't see why you need to use a completely different instance of various controls for every cell in the grid. If you have three different possible types of cells, then you only need three controls (or possibly as many as six if you allow editing) and three UltraControlContainerEditors and then you can re-use them for each cell that needs them.
In fact, if you really want this to be efficient, you only need one UltraControlContainerEditor and a single Control which can handle all three possibly types and display differently based on which type it is displaying. In other words, the RenderingControl could create or arrange controls within itself based on which type and the value it is displaying.
No luck.This solution is not applicable for us.Let me explain what we trying to achieve and how we are doing it.We have 5 grids in a form each displaying different data.The content in each cell can either be any of the following.1)User control 2)Combination of images and controls(label,progess bar etc).User control contains picture box,label,progess bar etc.Based on the value in the data set we are displaying the user controls or combination of images and controls (created dynamically).
We are binding these items to the container and then placing the container inside the cell.So the solution provided by Mike won't help us as data in each cell different.Mike suggested us to use the same container for displaying the same user control inside the grid.This won't help us as we are placing some other information inside the grid other than the user control.This information will be different for different cells eventhough the user control displayed is same.So we will have to use different containers for displaying the information.
We tried disposing the objects for each cell before rebinding the grid.Please find the methods mentioned below.
private static void DisposeObjects(UltraControlContainerEditor utraContainer) { if (utraContainer != null) { if ((utraContainer.RenderingControl.GetType().BaseType == typeof(UserControl))) { UserControl userControls = (UserControl)utraContainer.RenderingControl;
foreach (Control ctl in userControls.Controls) { if ((ctl.GetType() == typeof(TableLayoutPanel))) { TableLayoutPanel tblPnObj = (TableLayoutPanel)ctl; DisposeTableObjects(tblPnObj); } }
if (userControls.IsDisposed) { userControls.Dispose(); } } else { TableLayoutPanel tblpnl = (TableLayoutPanel)utraContainer.RenderingControl; DisposeTableObjects(tblpnl);
} utraContainer.Dispose(); GC.Collect(); } }
private static void DisposeTableObjects(TableLayoutPanel tblPnl) { Control cntrol = null; if (tblPnl != null) { foreach (Control ctl in tblPnl.Controls) { if ((ctl.GetType() == typeof(UltraPictureBox))) { UltraPictureBox picBoxObj = (UltraPictureBox)ctl; picBoxObj.Dispose(); }
if ((ctl.GetType() == typeof(UltraExpandableGroupBox))) { UltraExpandableGroupBox GroupBoxObj = (UltraExpandableGroupBox)ctl; GroupBoxObj.Dispose(); }
if ((ctl.GetType() == typeof(UltraButton))) { UltraButton buttonObj = (UltraButton)ctl; buttonObj.Dispose(); }
if ((ctl.GetType() == typeof(UltraLabel))) { UltraLabel buttonObj = (UltraLabel)ctl; buttonObj.Dispose(); } } }
}
Please suggest any other solution .
Thanks,
Prasant
I just wanted to know if you were able to solve your issue based on Mike's suggestions or you still need help. Just let me know.
Thank you
You don't need a different instance of the UltraControlContainerEditor or your control in order to display a different value in each cell of the grid. The UltraControlContainerEditor will use the grid cell's value and assign that value to the RenderingControl in order to paint the cell.
So unless you need to display some completely different UserControl in each cell of the grid, you should not have to do that.