Pregunta

Firstly, I apologise if this is a 'silly' question. I have searched extensively and cannot find an answer to this, but it seems like something that should be fairly simple.

I have a Windows Forms application that has some controls for which I want to set the modifier to public: static. This is not an option in designer view (it has public, public protected, etc.). I go to the code and change, for example,

public: System::Windows::Forms::ProgressBar^ progressBar1;

to

public: static System::Windows::Forms::ProgressBar^ progressBar1;

but if I modify anything in designer view, the "public" modifier overwrites my changes to the code. It is easy to keep going back to the code and changing it if need be, but this is very time consuming.

It doesn't seem to be the sort of question that requires showing a lot of code, but if you want to see any of my code, just ask and I'll happily post it.

Thanks in advance for any help.

¿Fue útil?

Solución

So it turns out that setting the control itself to static is not desirable, and there probably is no way to prevent VS from removing "static" from the code. I found a solution that solves my problem (which is that I wanted to access/modify the form's controls from another function) here:

http://social.msdn.microsoft.com/forums/en-US/Vsexpressvc/thread/dcc8228d-6937-450d-b4e2-e833fb1f388b/

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top