CODE
namespace Definitions
{
public partial class Form46 : Form
{
public Form46()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Hello World.");
}
}
}
OUTPUT
Form46
×
×
Hello World.
CODE
namespace Definitions
{
public partial class Form47 : Form
{
public Form47()
{
InitializeComponent();
}
private void btnDisplay_Click(object sender, EventArgs e)
{
label1.Text = textBox1.Text;
}
}
}
OUTPUT
Form47
×
Hello C#!
Hello C#!
CODE
namespace Definitions
{
public partial class Form48 : Form
{
public Form48()
{
InitializeComponent();
}
private void btnAdd_Click(object sender, EventArgs e)
{
try
{
double num1 = Convert.ToDouble(txtNum1.Text);
double num2 = Convert.ToDouble(txtNum2.Text);
lblResult.Text = "Result: " + (num1 + num2).ToString();
}
catch (Exception)
{
lblResult.Text = "Invalid Input";
}
}
// Similar click events would be added for Subtract, Multiply, and Divide buttons
}
}
OUTPUT
Calculator
×
25
5
Result: 30
CODE
namespace Definitions
{
public partial class Form49 : Form
{
public Form49()
{
InitializeComponent();
}
private void btnChangeColor_Click(object sender, EventArgs e)
{
// Changes the background color of the current form instance
this.BackColor = Color.LightBlue;
}
}
}
OUTPUT
Form49
×
CODE
namespace Definitions
{
public partial class Form50 : Form
{
public Form50()
{
InitializeComponent();
}
private void Form50_Load(object sender, EventArgs e)
{
// Adding array of countries to ComboBox on form load
string[] countries = { "India", "USA", "Canada", "Australia", "Japan" };
comboBox1.Items.AddRange(countries);
// Set default selected index
comboBox1.SelectedIndex = 0;
}
}
}
OUTPUT
Select Country Form
×
Select a Country:
India
▼
No comments:
Post a Comment