I'm making a console application that shows a form. I created the form from scratch. When I run the program, the form shows, but the controls I added don't show.
My code:
using System;
using System.Windows.Forms;
using System.Drawing;
namespace form
{
public class main
{
public static void Main()
{
Application.EnableVisualStyles();
Application.Run(new FrmLogin());
}
}
public class FrmLogin : Form
{
public void Frm()
{
this.Size = new Size(400, 600);
Button btn = new Button();
btn.Text = "Something";
btn.Size = new Size(10, 10);
btn.Location = new Point(10, 10);
btn.UseVisualStyleBackColor = true;
this.Controls.Add(btn);
}
}
}
You're never calling your
FrmLogin.Frm
method. If you intend this to be a constructor, drop thevoid
and rename it toFrmLogin
, like so:If you want instead to call it from the constructor, add a constructor called
FrmLogin
and have it callFrm
, like so: