Question: using System; using System.Windows.Forms; namespace LoginFormApp { public partial class Form 1 : Form { public Form 1 ( ) { InitializeComponent ( ) ;

using System;
using System.Windows.Forms;
namespace LoginFormApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
// Populate the gender ComboBox
comboBoxGender.Items.Add("Male");
comboBoxGender.Items.Add("Female");
comboBoxGender.Items.Add("Other");
}
private void buttonSubmit_Click(object sender, EventArgs e)
{
// Validate and process the input
string name = textBoxName.Text.Trim();
string surname = textBoxSurname.Text.Trim();
string gender = comboBoxGender.SelectedItem as string;
if (string.IsNullOrEmpty(name)|| string.IsNullOrEmpty(surname)|| string.IsNullOrEmpty(gender))
{
MessageBox.Show("Please fill in all fields.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
// Display a welcome message
string welcomeMessage = $"Welcome, {name}{surname}! Gender: {gender}";
MessageBox.Show(welcomeMessage, "Welcome", MessageBoxButtons.OK, MessageBoxIcon.Information);
// Clear the form after submission
textBoxName.Clear();
textBoxSurname.Clear();
comboBoxGender.SelectedIndex =-1;
}
}
}
} check this code and screenshots needed

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!