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

Code

The document defines a form for student registration that contains controls to capture a student's name, gender, and date of birth. It includes code to populate dropdowns for days, months, and years. When the form is submitted, it formats and displays the captured student information in a message box.

Uploaded by

Matthew Santos
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)
16 views

Code

The document defines a form for student registration that contains controls to capture a student's name, gender, and date of birth. It includes code to populate dropdowns for days, months, and years. When the form is submitted, it formats and displays the captured student information in a message box.

Uploaded by

Matthew Santos
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/ 3

namespace StudentRegistrationForms

{
public partial class Form1 : Form

public Form1()

InitializeComponent();

for (int day = 1; day <= 31; day++)

comboBox1.Items.Add(day);

}
comboBox1.SelectedIndex = 0;

for (int month = 1; month <= 12; month++)

comboBox2.Items.Add(month);

int currentYR = DateTime.Now.Year;

for (int YR = 1950; YR <= currentYR; YR++)

comboBox3.Items.Add(YR);

private void button1_Click(object sender, EventArgs e)

String Last = ToTitleCase(textBox1.Text);


String First = ToTitleCase(textBox2.Text);

String Middle = ToTitleCase(textBox3.Text);

String Gender = radioButton1.Checked ? "male" : "female";

int day = (int)comboBox1.SelectedItem;

int month = (int)comboBox2.SelectedItem;

int year = (int)comboBox3.SelectedItem;

String message = $"Student Name: {First} {Middle} {Last} \n" + $"Gender: {Gender} \
n" + $"Date of birth: {day}/{month}/{year}";

MessageBox.Show(message, "Student's Information");

private string ToTitleCase(string input)

return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(input.ToLower());

You might also like