Sign in to follow this  

no static Main problem

This topic is 2850 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to write a program in C# where I have two group boxes of Radio Buttons, and a Panel where I can "draw". What I need to do is basically write a paint type program. One set of Radio buttons changes the color and the other set changes size. I've got it wrote the way I think it needs to be but I'm getting a no static Main method. using System; using System.Drawing; using System.Windows.Forms; namespace DrawingPanel { public partial class frmDrawingPanel : Form { bool shouldPaint = false; private Color m_Color; private Size m_Size; Brush brush; int x; int y; int width; int height; public frmDrawingPanel() { InitializeComponent(); } private void frmDrawingPanel_MouseDown(object sender, MouseEventArgs e) { shouldPaint = true; } private void frmDrawingPanel_MouseUp(object sender, MouseEventArgs e) { shouldPaint = false; } private void rdbRed_CheckedChanged(object sender, EventArgs e) { m_Color = Color.Red; } private void rdbBlue_CheckedChanged(object sender, EventArgs e) { m_Color = Color.Blue; } private void rdbGreen_CheckedChanged(object sender, EventArgs e) { m_Color = Color.Green; } private void rdbBlack_CheckedChanged(object sender, EventArgs e) { m_Color = Color.Black; } private void rdbSmall_CheckedChanged(object sender, EventArgs e) { m_Size = new Size(4, 4); } private void rdbMedium_CheckedChanged(object sender, EventArgs e) { m_Size = new Size(6, 6); } private void rdbLarge_CheckedChanged(object sender, EventArgs e) { m_Size = new Size(12, 12); } private void frmDrawingPanel_MouseMove(object sender, MouseEventArgs e) { if (shouldPaint) { Graphics graphics = CreateGraphics(); graphics.FillEllipse( new SolidBrush(m_Color), e.X, e.Y, height, width); graphics.Dispose(); } } } } This is my code as of right now. If somebody can help me I'd really appreciate it. Thank you.

Share this post


Link to post
Share on other sites
1) Use [source] tags.
2) frmDrawingPanel? Just about every .NET naming convention ever recommends class names start with a capital.
3) All standard .NET programs must have a 'Main' method, which is where exectuion starts. Try this one on for size:

[STAThread] static void Main() {
Application.Run( new frmDrawingPanel() );
}

Share this post


Link to post
Share on other sites
It means exactly what it says. 'Main' is where the program starts running. You've told the compiler what a frmDrawingPanel is, how to create it, and what it can do (and how), but you have not told it to create one, nor what it should do (out of the things that it can).

Moving to For Beginners.

Share this post


Link to post
Share on other sites

This topic is 2850 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this