error loading c# class in visual studio - "class can be designed"

  • Thread starter Thread starter Steve Richter
  • Start date Start date
S

Steve Richter

here is an error I get when I open my class library project:

"The class ResultsTable 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 try loading the designer again."

What does that mean, "the class xxx can be designed"?

thanks,
-Steve

here is the class:

// ------------------ ResultsTable ----------------------
public class ResultsTable : System.Data.DataTable
{
public ResultsTable( )
{
AddColumns( ) ;
}

private void AddColumns( )
{
Columns.Add(new DataColumn("Title", typeof(string)));
Columns.Add(new DataColumn("Author", typeof(string)));
}

public ResultsTableRow NewResultsTableRow( )
{
DataRow row = base.NewRow( ) ;
ResultsTableRow row2 = new ResultsTableRow( row ) ;
return row2 ;
}
}
 
Steve,

It means that the class has a designer for it, but the designer can't
render it, because one of the requirements is that the class that is being
designed be the first class in the file.

Take the other classes out of the file and place them in separate files,
or place the class that has a designer associated with it in another file.

Hope this helps.
 
I think what it means is that the class ResultsTable doesn't have any
problems that would prevent it from rendering the GUI in the designer.
However, you have a class defined above it, which VS.NET doesn't like. I
give each class its own file, which is a technique that would also solve
your problem.

Joe
 
Nicholas said:
Steve,

It means that the class has a designer for it, but the designer can't
render it, because one of the requirements is that the class that is being
designed be the first class in the file.

Take the other classes out of the file and place them in separate files,
or place the class that has a designer associated with it in another file.

Hope this helps.

thanks for the help. I am being lazy and have to read up on what a
designer is. Just odd that System.Data.DataTable as a base class would
trigger all that built in behavior in Visual Studio.

-Steve
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Steve Richter said:
here is an error I get when I open my class library project:

"The class ResultsTable 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 try loading the designer again."

What does that mean, "the class xxx can be designed"?

thanks,
-Steve

here is the class:

// ------------------ ResultsTable ----------------------
public class ResultsTable : System.Data.DataTable
{
public ResultsTable( )
{
AddColumns( ) ;
}

private void AddColumns( )
{
Columns.Add(new DataColumn("Title", typeof(string)));
Columns.Add(new DataColumn("Author", typeof(string)));
}

public ResultsTableRow NewResultsTableRow( )
{
DataRow row = base.NewRow( ) ;
ResultsTableRow row2 = new ResultsTableRow( row ) ;
return row2 ;
}
}
 
Back
Top