This one comes up in the forums at least once a week. The scenario is where someone shows a form, closes it while retaining the handle, and then tries to show it again by calling Show or ShowDialog on the closed form. This throws an exception that says the object has been disposed. Here’s my [...]
Entries Tagged as 'Windows Forms'
FAQ: Cannot re-show a WinForms form that’s been closed
June 4th, 2010 · 1 Comment
Tags: FAQ · Windows Forms
Checking for Design-Mode
June 21st, 2009 · 2 Comments
The DesignMode property does not always return the correct value, specially for nested controls or for child controls instantiated in their parent control’s constructors. One workaround is to check for LicenseManager.UsageMode and see if it’s equal to LicenseUsageMode.Runtime, but even that won’t work all the time. It will always return Runtime from event handlers and [...]
Tags: C#/.NET · Windows Forms
Adding a DockStyle.Fill control at run-time
June 7th, 2008 · 2 Comments
This one was simple to resolve but it did halt my progress for about 5-6 minutes recently. I had a form (actually a user control) that had a control on it added at design time docked to the right. During run time I was adding a new WinForms control that I had set to DockStyle.Fill. [...]
Tags: CLR/.NET BCL · Windows Forms