Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions