Can anyone explain why this behaviour might be happening in Windows Forms?

Posted by gizgok on Stack Overflow See other posts from Stack Overflow or by gizgok
Published on 2012-01-03T09:10:21Z Indexed on 2012/06/18 9:16 UTC
Read the original article Hit count: 172

Filed under:

I'm developing a Windows Forms Application. See attached image for the InterfaceApp. Now I've put a close button (X) in the Panel(say Panel2) which has Application Constants as label.The first combo box is in another panel(say Panel1). Now when I click on the X button in Panel 2 I want the Panel to be invisible and the combo box text to be blank. Simple enough. So I write

Panel2.visible=false;
comboBox1.SelectedIndex=-1;

When I click on X, the text in combo box goes blank, then I have to click again for the Panel2 to go invisible.

Then I changed the sequence

comboBox1.SelectedIndex=-1;
Panel2.visible=fasle;

and this works smooth. Not sure why this might be happening? Is there anything that I might be doing with my form design/code to have such a behaviour?

© Stack Overflow or respective owner

Related posts about winforms