0% found this document useful (0 votes)
13 views

C sharp slybs

Uploaded by

Muhammad Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

C sharp slybs

Uploaded by

Muhammad Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1: How we create a simple form in C sharp

using System;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
2: How we use load command in C sharp form
using System;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)


{

}
}
}
3: How we make a button in C sharp form
using System;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{

}
}
}
4: How we show a message on clicking a button
And change background color of a button
using System;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
MessageBox.Show("Hello from button 1");
button1.BackColor = Color.Aqua;
}
}
}

5: How we create as combo box in c sharp and add


elments in

using System;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void comboBox1_SelectedIndexChanged(object sender,


EventArgs e)
{

}
}
}

// By using query.
using System;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)


{
comboBox1.Items.Add("Mango");
comboBox1.Items.Add("Banana");
comboBox1.Items.Add("Dates");
comboBox1.Items.Add("Apple");
comboBox1.Items.Add("Gava");
}
}
}

// by using list.

using System;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{

List<string> list = new List<string>()


{
"Mango","Apple","Dates","Banana","Grapes"
};
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)


{
comboBox1.DataSource = list;
}
}
}

6: how we create a label in c sharp formusing System;


using System;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void label1_Click(object sender, EventArgs e)


{

}
}
}

You might also like