Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Emma’s Custom Embroidery sells shirts with detailed embroidered images. Emma all

ID: 665788 • Letter: E

Question

Emma’s Custom Embroidery sells shirts with detailed embroidered images. Emma allows users to select the color for a shirt, but she allows only specific embroidery designs with each shirt color. Create a project named EmmasEmbroidery that allows a user to choose one of four shirt colors from a ListBox—white, black, red, or blue. When the user selects a shirt color, the program should display a second ListBox that contains the following embroidery design choices:

•   White shirt—peacock, palm tree, or rose

•   Black shirt—race car, star, or moon

•   Red shirt—palm tree or moon

•   Blue shirt—peacock or moon

After the user selects an embroidery design, the program should display a congratulatory message on a Label indicating that the choice is a good one, and the design ListBox also becomes invisible. If the user makes a new selection from the shirt color ListBox, the congratulatory message is invisible until the user selects a complementary design.

Hint: You can remove the entire contents of a ListBox using the Items.Clear() method, as in this.listBox1.Items.Clear();. (Farrell 670)

.

Explanation / Answer

As per the question a C# application is being created .It has basically winform application which is having the list boxes.

The project (EmmasEmbroidery) is having mainly 2 files one EmmasEmbroideryMainForm.cs and EmmasEmbroideryMainForm.Designer.cs.

Below is the code for the same.

----------------------------------------------------------------------------------

EmmasEmbroideryMainForm.cs

---------------------------------------------------------------------------------

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 EmmasEmbroidery
{
public partial class EmmasEmbroideryMainForm : Form
{
private const string White = "White";
private const string Black = "Black";
private const string Red = "Red";
private const string Blue = "Blue";

public EmmasEmbroideryMainForm()
{
InitializeComponent();
this.listBoxDesignChoices.Visible = false;
this.labelMesage.Visible = false;
}

private void listBoxShirtColors_SelectedIndexChanged(object sender, EventArgs e)
{
this.labelMesage.Visible = false;
this.listBoxDesignChoices.Items.Clear();
string selectedItem = listBoxShirtColors.SelectedValue != null ?
listBoxShirtColors.SelectedValue.ToString():
string.Empty;
  
switch (selectedItem)
  
{
case White:
this.listBoxDesignChoices.Items.AddRange(new string[]{"Peacock", "Palm Tree", "Rose"});
break;

case Black:
this.listBoxDesignChoices.Items.AddRange(new string[] { "Race Car", "Star", "Moon" });
break;

case Red:
this.listBoxDesignChoices.Items.AddRange(new string[] { "Palm Tree", "Moon"});
break;

case Blue:
this.listBoxDesignChoices.Items.AddRange(new string[] { "Peacock", "Moon" });
break;

default:
break;
}

this.listBoxDesignChoices.Visible = true;
}

private void listBoxDesignChoices_SelectedValueChanged(object sender, EventArgs e)
{
string selectedItem = listBoxDesignChoices.SelectedValue != null ?
listBoxShirtColors.SelectedValue.ToString() :
string.Empty;

this.labelMesage.Text = string.Format("Congratution !!! you have selected [{0}] which is really good.",
selectedItem
);
this.labelMesage.Visible = true;
this.listBoxDesignChoices.Visible = false;
}
}
}

----------------------------------------------------------------------------------------------------------

EmmasEmbroideryMainForm.Designer.cs

---------------------------------------------------------------------------------------------------------

namespace EmmasEmbroidery
{
partial class EmmasEmbroideryMainForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.listBoxShirtColors = new System.Windows.Forms.ListBox();
this.label1 = new System.Windows.Forms.Label();
this.listBoxDesignChoices = new System.Windows.Forms.ListBox();
this.label2 = new System.Windows.Forms.Label();
this.labelMesage = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// listBoxShirtColors
//
this.listBoxShirtColors.FormattingEnabled = true;
this.listBoxShirtColors.Items.AddRange(new object[] {
"White",
"Black",
"Red",
"Blue"});
this.listBoxShirtColors.Location = new System.Drawing.Point(12, 53);
this.listBoxShirtColors.Name = "listBoxShirtColors";
this.listBoxShirtColors.Size = new System.Drawing.Size(117, 134);
this.listBoxShirtColors.TabIndex = 0;
this.listBoxShirtColors.SelectedIndexChanged += new System.EventHandler(this.listBoxShirtColors_SelectedIndexChanged);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 37);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(60, 13);
this.label1.TabIndex = 1;
this.label1.Text = "Shirt Colors";
//
// listBoxDesignChoices
//
this.listBoxDesignChoices.FormattingEnabled = true;
this.listBoxDesignChoices.Location = new System.Drawing.Point(334, 53);
this.listBoxDesignChoices.Name = "listBoxDesignChoices";
this.listBoxDesignChoices.Size = new System.Drawing.Size(120, 134);
this.listBoxDesignChoices.TabIndex = 2;
this.listBoxDesignChoices.SelectedValueChanged += new System.EventHandler(this.listBoxDesignChoices_SelectedValueChanged);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(334, 37);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(81, 13);
this.label2.TabIndex = 3;
this.label2.Text = "Design Choices";
//
// labelMesage
//
this.labelMesage.AutoSize = true;
this.labelMesage.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.labelMesage.Location = new System.Drawing.Point(94, 223);
this.labelMesage.Name = "labelMesage";
this.labelMesage.Size = new System.Drawing.Size(0, 13);
this.labelMesage.TabIndex = 4;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(584, 562);
this.Controls.Add(this.labelMesage);
this.Controls.Add(this.label2);
this.Controls.Add(this.listBoxDesignChoices);
this.Controls.Add(this.label1);
this.Controls.Add(this.listBoxShirtColors);
this.Name = "Form1";
this.Text = "EmmasEmbroidery ";
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.ListBox listBoxShirtColors;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ListBox listBoxDesignChoices;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label labelMesage;
}
}

-----------------------------------------------------------------------------------------------------

Program.cs

----------------------------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace EmmasEmbroidery
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new EmmasEmbroideryMainForm());
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote