468,136 Members | 1,435 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,136 developers. It's quick & easy.

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

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 ;
}
}

Nov 17 '05 #1
3 10569
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.
--
- Nicholas Paldino [.NET/C# MVP]
- ca*******@caspershouse.com

"Steve Richter" <St************@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
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 ;
}
}

Nov 17 '05 #2
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
--
http://www.csharp-station.com

"Steve Richter" <St************@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
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 ;
}
}

Nov 17 '05 #3

Nicholas Paldino [.NET/C# MVP] wrote:
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]
- ca*******@caspershouse.com

"Steve Richter" <St************@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
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 ;
}
}


Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by mshetty | last post: by
5 posts views Thread by Francis Shanahan | last post: by
1 post views Thread by Larry Van Der Jagt | last post: by
5 posts views Thread by crystalattice | last post: by
1 post views Thread by Martin Plechsmid | last post: by
27 posts views Thread by didacticone | last post: by
1 post views Thread by gcdp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.