CODE
namespace Definitions
{
public partial class Form51 : Form
{
public Form51()
{
InitializeComponent();
}
private void btnAdd_Click(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(txtInput.Text))
{
listBox1.Items.Add(txtInput.Text);
txtInput.Clear();
}
}
private void btnRemove_Click(object sender, EventArgs e)
{
if (listBox1.SelectedIndex != -1)
{
listBox1.Items.RemoveAt(listBox1.SelectedIndex);
}
}
}
}
OUTPUT
Dynamic ListBox
×
Apple
Banana
Orange
Mango...
CODE
namespace Definitions
{
public partial class Form52 : Form
{
public Form52()
{
InitializeComponent();
}
private void Form52_Load(object sender, EventArgs e)
{
// Assuming "image.jpg" is in the debug folder or resources
pictureBox1.ImageLocation = "image.jpg";
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
}
}
}
OUTPUT
Image Viewer
×
🖼️
CODE
namespace Definitions
{
public partial class Form53 : Form
{
public Form53()
{
InitializeComponent();
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("My Application v1.0");
}
}
}
OUTPUT
MenuStrip Example
×
File
Help
New
Open...
Exit
CODE
namespace Definitions
{
public partial class Form54 : Form
{
public Form54()
{
InitializeComponent();
}
private void toolStripButtonSave_Click(object sender, EventArgs e)
{
MessageBox.Show("Save clicked!");
}
}
}
OUTPUT
ToolStrip Example
×
⚙️ ▼
CODE
namespace Definitions
{
public partial class Form55 : Form
{
public Form55()
{
InitializeComponent();
timer1.Interval = 1000; // 1 second
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
lblTime.Text = DateTime.Now.ToString("hh:mm:ss tt");
}
}
}
OUTPUT
Digital Clock
×
03:28:06 PM
CODE
namespace Definitions
{
public partial class Form56 : Form
{
public Form56()
{
InitializeComponent();
}
// No specific code required for purely visual containers
// Controls are dragged and dropped into Panel and GroupBox via Designer
}
}
OUTPUT
Containers Example
×
Hobbies Panel
CODE
namespace Definitions
{
public partial class Form57 : Form
{
public Form57()
{
InitializeComponent();
}
private void btnPickColor_Click(object sender, EventArgs e)
{
if (colorDialog1.ShowDialog() == DialogResult.OK)
{
this.BackColor = colorDialog1.Color;
}
}
}
}
OUTPUT
Color Dialog Result
×
CODE
namespace Definitions
{
public partial class Form58 : Form
{
public Form58()
{
InitializeComponent();
}
private void btnChangeFont_Click(object sender, EventArgs e)
{
if (fontDialog1.ShowDialog() == DialogResult.OK)
{
textBox1.Font = fontDialog1.Font;
textBox1.ForeColor = fontDialog1.Color;
}
}
}
}
OUTPUT
Font Dialog Example
×
Customized Text Output
CODE
namespace Definitions
{
public partial class Form59 : Form
{
public Form59()
{
InitializeComponent();
}
private void btnBrowse_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "Image Files|*.jpg;*.jpeg;*.png;*.bmp";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
pictureBox1.Image = Image.FromFile(openFileDialog1.FileName);
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
}
}
}
}
OUTPUT
Open Image Viewer
×
🌄
CODE
using System.IO;
namespace Definitions
{
public partial class Form60 : Form
{
public Form60()
{
InitializeComponent();
}
private void btnSave_Click(object sender, EventArgs e)
{
saveFileDialog1.Filter = "Text Files (*.txt)|*.txt";
saveFileDialog1.DefaultExt = "txt";
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
File.WriteAllText(saveFileDialog1.FileName, textBox1.Text);
MessageBox.Show("File saved successfully!");
}
}
}
}
OUTPUT
Simple Text Editor
×
No comments:
Post a Comment