how to destroy window handle
-
I have a user control (composed of 10 text boxes). on certain user inputs -> multiple rows of above user control are added to a form. After certain amount of operation, I start getting error - cannot create window handle. How do I need to clear window handle? Shouldn't it be automatically disposed?
Gurpreet
-
I have a user control (composed of 10 text boxes). on certain user inputs -> multiple rows of above user control are added to a form. After certain amount of operation, I start getting error - cannot create window handle. How do I need to clear window handle? Shouldn't it be automatically disposed?
Gurpreet
-
accordance to google (some links), the problem comes only if you have too many loaded/visible usercontrol at the same time. for example, 1000 controls loaded at same time. try to reduce what you want to show. don't show all of them at once.
I do not want to show them all at once. At a time say 100 are visible but after the user changes the input I need to show other 100. But how do a ensure that the handle is destroyed for previous ones?
Gurpreet
-
I do not want to show them all at once. At a time say 100 are visible but after the user changes the input I need to show other 100. But how do a ensure that the handle is destroyed for previous ones?
Gurpreet
-
I have a user control (composed of 10 text boxes). on certain user inputs -> multiple rows of above user control are added to a form. After certain amount of operation, I start getting error - cannot create window handle. How do I need to clear window handle? Shouldn't it be automatically disposed?
Gurpreet
So you have 100 visible UserControls with 10 TextBoxes each, and a lot of invisible ones? That is a bad design. If you need that many user inputs, use a listing control, maybe a DataGridView. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use < PRE > tags for code snippets, it preserves indentation, and improves readability.
-
I have a user control (composed of 10 text boxes). on certain user inputs -> multiple rows of above user control are added to a form. After certain amount of operation, I start getting error - cannot create window handle. How do I need to clear window handle? Shouldn't it be automatically disposed?
Gurpreet
KaurGurpreet wrote:
How do I need to clear window handle?
You don't. That's handled by the controls themselves. If you're running into this problem, it could be that your Showing a form with ShowDialog (not Show!), but never Disposing it when you're done. Just because you can't see the form anymore doesn't mean it's gone. If you don't Dispose the form, you're leaking resources (handles). This issue does not come up if the form is shown with the Show method. If you're putting up hundreds and hundreds of controls, your design is the problem, not the window handles being released.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009...