//using System; //using System.Collections.Generic; //using System.ComponentModel; //using System.Data; //using System.Drawing; //using System.Linq; //using System.Text; //using System.Threading.Tasks; //using System.Windows.Forms; //namespace Card //{ // public partial class Form1 : Form // { // public Form1() // { // InitializeComponent(); // } // private void pictureBox1_Click(object sender, EventArgs e) // { // } // private void pictureBox2_Click(object sender, EventArgs e) // { // } // private void pictureBox3_Click(object sender, EventArgs e) // { // } // private void listBox1_SelectedIndexChanged(object sender, EventArgs e) // { // } // private void button1_Click(object sender, EventArgs e) // { // } // private void button2_Click(object sender, EventArgs e) // { // } // } //} using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Card { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void pictureBox1_Click(object sender, EventArgs e) { } private void pictureBox2_Click(object sender, EventArgs e) { } private void pictureBox3_Click(object sender, EventArgs e) { } private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { // Optional: enable/disable the Show Card button based on selection button1.Enabled = listBox1.SelectedItem != null; } private void button1_Click(object sender, EventArgs e) { var selected = listBox1.SelectedItem as string; if (string.IsNullOrWhiteSpace(selected)) { MessageBox.Show("Please select a card from the list.", "No selection", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } // Normalize for case-insensitive comparison switch (selected.Trim().ToLowerInvariant()) { case "ace of spades": pictureBox1.Visible = true; pictureBox2.Visible = false; pictureBox3.Visible = false; break; case "10 hearts": pictureBox1.Visible = false; pictureBox2.Visible = true; pictureBox3.Visible = false; break; case "king club": pictureBox1.Visible = false; pictureBox2.Visible = false; pictureBox3.Visible = true; break; case "all card": case "all cards": pictureBox1.Visible = true; pictureBox2.Visible = true; pictureBox3.Visible = true; break; default: MessageBox.Show("Unknown selection.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } } private void button2_Click(object sender, EventArgs e) { // Exit the form/application this.Close(); } private void Form1_Load(object sender, EventArgs e) { } } }