0% found this document useful (0 votes)
31 views6 pages

Ass2 Ap Sol

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

Ass2 Ap Sol

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

Q 03:

Code:

using System;
using System.Windows.Forms;

namespace ControlsDemo
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}

private void timer1_Tick(object sender, EventArgs e)


{
// Update the progress bar value
progressBar1.Value += 10;
// Stop the timer when progress reaches maximum
if (progressBar1.Value >= progressBar1.Maximum)
{
timer1.Stop();
MessageBox.Show("Progress complete!");
}
}

private void startButton_Click(object sender, EventArgs e)


{
// Start the timer
timer1.Start();
}

private void stopButton_Click(object sender, EventArgs e)


{
// Stop the timer
timer1.Stop();
}

private void MainForm_Load(object sender, EventArgs e)


{
// Initialize the progress bar
progressBar1.Minimum = 0;
progressBar1.Maximum = 100;
progressBar1.Value = 0;

// Set up the timer


timer1.Interval = 1000; // 1 second
}

private void numericUpDown1_ValueChanged(object sender, EventArgs e)


{
// Display the value of the NumericUpDown control in the RichTextBox
richTextBox1.AppendText("NumericUpDown value changed: " +
numericUpDown1.Value.ToString() + Environment.NewLine);
}

private void maskedTextBox1_MaskInputRejected(object sender,


MaskInputRejectedEventArgs e)
{
// Display error message when input is rejected in the MaskedTextBox
MessageBox.Show("Input rejected in MaskedTextBox");
}
}
}

Q 04:
Code:

using System;
using System.Windows.Forms;

namespace DataEntryApp
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}

private void MainForm_Load(object sender, EventArgs e)


{
// Set the DateTimePicker format to Short which shows date only
dateTimePicker1.Format = DateTimePickerFormat.Short;
// Set the DateTimePicker value to current date
dateTimePicker1.Value = DateTime.Now;
}

private void numericTextBox_KeyPress(object sender, KeyPressEventArgs e)


{
// Allowing only numeric input and backspace
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar))
{
e.Handled = true;
}
}

private void capitalAlphabetTextBox_KeyPress(object sender, KeyPressEventArgs e)


{
// Allowing only capital alphabet input and backspace
if (!char.IsControl(e.KeyChar) && !char.IsUpper(e.KeyChar))
{
e.Handled = true;
}
}
private void smallAlphabetTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
// Allowing only small alphabet input and backspace
if (!char.IsControl(e.KeyChar) && !char.IsLower(e.KeyChar))
{
e.Handled = true;
}
}
}
}

You might also like