Pregunta

i am developing a winform application which has an owner drawn combobox with check boxes. but in visual studio i am facing following erroe

" The class CheckComboBox can be designed, but is not the first class in the file. Visual Studio requires that designers use the first class in the file. Move the class code so that it is the first class in the file "

and how to Move the class code so that it is the first class in the file ??

i checked previous posts regarding the same but not getting it.

please help.. thanks in advance.

¿Fue útil?

Solución 3

Finally i got the answer. i was reading the error and suddenly it clicked. in the namespace, CheckComboBox should be the first class ( means it should be always the first class and if you have any other class in the namespace, put it after)

    namespace **xyz**
 {
     class **xyz** 
     {
     }  
     class pqr 
     {
     }
}

Otros consejos

The simplest way is to create separate file for each class that you write. It will resolve the issue and is considered a good practice.

If you cannot/won't then simply select whole class content cut it and paste it under namespace opening {.

you have to create seperate namespaces for all the UI part as the designer file sitting behind windows form also tries to find the namespace, but when it does not find the same namespace, it thinks that the classes are different. To fix this include the code in the Designer file in the same namespace

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