Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I'm having this strange issue that's been driving me mad!

I simply cannot change the control's properties at runtime after I publish my application. Example: I have two buttons on my form, button1 and button2. On button1's OnClick event, I have the following code:

button2.Visible = false;


But this simply does not work. Button2 remains visible. The same problem happens if I try to change any of the button's properties (Enabled, for instance).

This only happens after I publish and install my clickonce app. If I run the app on Visual Studio, everything works fine.

Has anyone ever seen this before?

Thanks.
Posted
Comments
R. Giskard Reventlov 8-Jul-11 5:34am    
Are you sure the updated app is getting properly published?
aureliosjr 8-Jul-11 5:38am    
Yes, I am. I made visual changes to the app to make sure it was beeing correctly updated.

Ensure that your publish worked properly. It sounds like that is your issue. If you need to, check some other change that happened as well if possible. Is there any other code running in button1_click? If so, validate that the code is still executing. If it is, then your publish failed. If it isn't, then your handler simply isn't firing properly and you have other issues to sort out.
 
Share this answer
 
Comments
aureliosjr 11-Jul-11 4:27am    
Thanks for your answer, but the publish is working properly. Every single change I make to the application shows up correctly on the published version. I tried putting some more code in button1_click, and it does execute normally. I used a "MessageBox.Show" to test it, and the message gets displayed.
After losing a few years of life troubleshooting this problem, I finally found it's ridiculously obvious cause (isn't it always like that?): there were two calls to the "InitializeComponent" method. I hope this at least helps someone else who might make this stupid mistake.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900