Hi guys. I'm writing a basic script in C# and there's a few areas where I am stuck, and I was wondering if you may be able to help me?
1) Can you embed an image into the source code so it will show in the windows GUI?
2) Can you change the background of the GUI?
3) How do you add an .ico to the source code so the icon looks better then the boring standard box and the top left image changes in the GUI?
If it helps here is my source code so far;
using System ;
using System.Windows.Forms ;
public class login
{
static TextBox txt1 = new TextBox() ;
static TextBox txt2 = new TextBox() ;
static Button btn1 = new Button() ;
static Label sysMsg = new Label() ;
static Label usrMsg = new Label() ;
static Label pwdMsg = new Label() ;
public static void Main()
{
Form frmMain = new Form() ;
frmMain.Text = "Login Client" ;
frmMain.StartPosition = FormStartPosition.CenterScreen ;
frmMain.Closed += new EventHandler(frmMain_Closed) ;
txt1.Location = new System.Drawing.Point(100,10) ;
txt2.Location = new System.Drawing.Point(100,50) ;
btn1.Text = "Login" ;
btn1.Location = new System.Drawing.Point(10,100) ;
btn1.Click += new EventHandler(btn1_Click) ;
usrMsg.Text = "Username" ;
usrMsg.AutoSize = true ;
usrMsg.Location = new System.Drawing.Point(10,15) ;
pwdMsg.Text = "Password" ;
pwdMsg.AutoSize = true ;
pwdMsg.Location = new System.Drawing.Point(10,55) ;
sysMsg.Text = " " ;
sysMsg.AutoSize = true ;
sysMsg.Location = new System.Drawing.Point(10,130) ;
frmMain.Controls.Add( txt1 ) ;
frmMain.Controls.Add( txt2 ) ;
frmMain.Controls.Add( btn1 ) ;
frmMain.Controls.Add( sysMsg ) ;
frmMain.Controls.Add( usrMsg ) ;
frmMain.Controls.Add( pwdMsg ) ;
frmMain.Show() ;
Application.Run() ;
}
private static void frmMain_Closed( object sender, System.EventArgs e)
{
Application.Exit() ;
}
private static void btn1_Click( object s, System.EventArgs e)
{
sysMsg.Text = ( txt1.Text.Equals( String.Empty ) ) ? "Incorrect Username or Password" : "Logging in..." ;
}
}
Cheers
Jamie