Declare, define a varibale in a windows form application
-
Hello guys, I've the following problem: I want to declare a variable and set its value in a windows form outside a function, but when I buid the the project, the following error occurs: "error C3845: only static data members can be initialized inside a ref class or value type". Declaring the variables as static works but when I want to declare an array, that doesn't. It's not possible to declare the class as non-ref-class. Does anyone have an idea how to manage this? Thanks for your help, and best wishes.
-
Hello guys, I've the following problem: I want to declare a variable and set its value in a windows form outside a function, but when I buid the the project, the following error occurs: "error C3845: only static data members can be initialized inside a ref class or value type". Declaring the variables as static works but when I want to declare an array, that doesn't. It's not possible to declare the class as non-ref-class. Does anyone have an idea how to manage this? Thanks for your help, and best wishes.
Austrian_Programmer wrote:
Declaring the variables as static works but when I want to declare an array, that doesn't.
How about showing us your code that is not working?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Hello guys, I've the following problem: I want to declare a variable and set its value in a windows form outside a function, but when I buid the the project, the following error occurs: "error C3845: only static data members can be initialized inside a ref class or value type". Declaring the variables as static works but when I want to declare an array, that doesn't. It's not possible to declare the class as non-ref-class. Does anyone have an idea how to manage this? Thanks for your help, and best wishes.
I strongly recommmend you move this post to the C# forum before toxcct gets hold of it... Is that the sound a flame thrower warming up [duck]...
Nothing is exactly what it seems but everything with seems can be unpicked.
-
Hello guys, I've the following problem: I want to declare a variable and set its value in a windows form outside a function, but when I buid the the project, the following error occurs: "error C3845: only static data members can be initialized inside a ref class or value type". Declaring the variables as static works but when I want to declare an array, that doesn't. It's not possible to declare the class as non-ref-class. Does anyone have an idea how to manage this? Thanks for your help, and best wishes.
Your code is managed or unmanaged?
-
Your code is managed or unmanaged?
Thanks for your help, I found a solution to the problem: I declare and define the variables in the InitializeComponents() function. By the way, does anyone know a tutorial for visual c++ windows forms using the windows forms project type of VS.NET? Thanks and best wishes.
-
Thanks for your help, I found a solution to the problem: I declare and define the variables in the InitializeComponents() function. By the way, does anyone know a tutorial for visual c++ windows forms using the windows forms project type of VS.NET? Thanks and best wishes.
I think you can find articles on the codeproject did you search?