Click here to Skip to main content
15,918,742 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: ComboBox issues Pin
tuga-x17-Oct-07 2:57
tuga-x17-Oct-07 2:57 
GeneralRe: ComboBox issues Pin
Luc Pattyn17-Oct-07 3:13
sitebuilderLuc Pattyn17-Oct-07 3:13 
GeneralRe: ComboBox issues Pin
tuga-x17-Oct-07 3:45
tuga-x17-Oct-07 3:45 
GeneralRe: ComboBox issues Pin
Luc Pattyn17-Oct-07 14:53
sitebuilderLuc Pattyn17-Oct-07 14:53 
GeneralRe: ComboBox issues Pin
tuga-x17-Oct-07 23:02
tuga-x17-Oct-07 23:02 
GeneralRe: ComboBox issues Pin
Luc Pattyn18-Oct-07 2:52
sitebuilderLuc Pattyn18-Oct-07 2:52 
GeneralRe: ComboBox issues Pin
tuga-x18-Oct-07 2:57
tuga-x18-Oct-07 2:57 
GeneralRe: ComboBox issues Pin
Patrick Etc.18-Oct-07 9:16
Patrick Etc.18-Oct-07 9:16 
tuga-x wrote:
Ok, so I'm not hallucinating, something really strange is going on here.

I'm inclined to think it's a bug, but I don't really know.

Obviously there are ways around this, but I shouldn't have to do them. I'm not doing anything special!


It's not a bug, you're abusing the framework and relying on an implementation detail that may change, and HAS changed between .NET 2.0 and .NET 3.0.

The detail you're relying on is that calling Dispose() on a control causes it to be removed from its parent's control collection.

What you DON'T know is that that call also destroys the control's handle, which is why your events are no longer being received. The event model relies on the handle being created to raise events (or in most cases, even receive them from the operating system - how do you think the OS knows which control to send the event to?). Dispose() on a Control ALSO kills the handle's message loop - you know, that pesky little thing that is actually dispatching the Windows messages that allow your events to be raised.

If you want to remove the control from the parent collection, do that. Don't invent some convoluted system of destruction just to remove a control from the parent collection.

To add a control to panel B:

comboBox1.Parent = panelb;

To remove the control from panel B:

comboBox1.Parent = null;

You should not be calling dispose anywhere in your code. Anywhere. Dispose() is one of those functions that should almost never need to be explicitly used.


"If you think of yourselves as helpless and ineffectual, it is certain that you will create a despotic government to be your master. The wise despot, therefore, maintains among his subjects a popular sense that they are helpless and ineffectual."
- Frank Herbert

GeneralRe: ComboBox issues Pin
Luc Pattyn18-Oct-07 9:42
sitebuilderLuc Pattyn18-Oct-07 9:42 
GeneralRe: ComboBox issues Pin
Patrick Etc.18-Oct-07 9:56
Patrick Etc.18-Oct-07 9:56 
GeneralRe: ComboBox issues Pin
Luc Pattyn18-Oct-07 10:41
sitebuilderLuc Pattyn18-Oct-07 10:41 
GeneralRe: ComboBox issues Pin
tuga-x18-Oct-07 22:19
tuga-x18-Oct-07 22:19 
QuestionValueType vs Reference Pin
rtalan17-Oct-07 0:16
rtalan17-Oct-07 0:16 
AnswerRe: ValueType vs Reference Pin
Robert Rohde17-Oct-07 0:27
Robert Rohde17-Oct-07 0:27 
GeneralRe: ValueType vs Reference Pin
rtalan17-Oct-07 0:48
rtalan17-Oct-07 0:48 
GeneralRe: ValueType vs Reference Pin
lmoelleb17-Oct-07 1:39
lmoelleb17-Oct-07 1:39 
GeneralRe: ValueType vs Reference Pin
rtalan17-Oct-07 1:53
rtalan17-Oct-07 1:53 
GeneralRe: ValueType vs Reference Pin
lmoelleb17-Oct-07 2:12
lmoelleb17-Oct-07 2:12 
GeneralRe: ValueType vs Reference Pin
rtalan17-Oct-07 2:42
rtalan17-Oct-07 2:42 
GeneralRe: ValueType vs Reference Pin
Luc Pattyn17-Oct-07 2:57
sitebuilderLuc Pattyn17-Oct-07 2:57 
GeneralRe: ValueType vs Reference Pin
rtalan17-Oct-07 3:31
rtalan17-Oct-07 3:31 
GeneralRe: ValueType vs Reference Pin
Luc Pattyn17-Oct-07 3:44
sitebuilderLuc Pattyn17-Oct-07 3:44 
GeneralRe: ValueType vs Reference Pin
lmoelleb17-Oct-07 4:46
lmoelleb17-Oct-07 4:46 
GeneralRe: ValueType vs Reference Pin
George L. Jackson17-Oct-07 12:24
George L. Jackson17-Oct-07 12:24 
GeneralRe: ValueType vs Reference Pin
DavidNohejl17-Oct-07 23:21
DavidNohejl17-Oct-07 23:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.