Question #56269

Create a Message Displayer that has one ComboBox object with a list of at least four of your favorite sayings. In your design, include the capability of letting users enter their own sayings. When a selection is made or a new entry is typed, display the selection on a Label object on your form. Add a menu to the application that includes at least the menu options of Format and Help. Under the Format selection, include options of Font and Color. Wire the Font and Color options to the Windows predefined Font and Color dialog boxes so that when their values are changed, the text in the Label object displaying the saying is changed.
1

Expert's answer

2016-01-19T08:28:40-0500

Answer on Question #56269 – Programming – C#

Create a Message Display that has one ComboBox object with a list of at least four of your favorite sayings. In your design, include the capability of letting users enter their own sayings. When a selection is made or a new entry is typed, display the selection on a Label object on your form. Add a menu to the application that includes at least the menu options of Format and Help. Under the Format selection, include options of Font and Color. Wire the Font and Color options to the Windows predefined Font and Color dialog boxes so that when their values are changed, the text in the Label object displaying the saying is changed.


using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace _56269
{
    public partial class Form1 : Form
    {
        BindingList<KeyValuePair<string, bool>> data;
        public Form1()
        {
            InitializeComponent();
            data = new BindingList<KeyValuePair<string, bool>>();
            comboBox1.DataSource = data;
            comboBox1.DisplayMember = "Key";
            label1.DataBindings.Add("Text", data, "Key", true, DataSourceUpdateMode.OnPropertyChanged);
            data.Add(new KeyValuePair<string, bool>("A day without laughter is a day wasted", false));
            data.Add(new KeyValuePair<string, bool>("The best way to resolve any problem is for all sides to sit down and talk", false));
            data.Add(new KeyValuePair<string, bool>("Don't worry if plan A fails, there are 25 more letters in the alphabet", false));
            data.Add(new KeyValuePair<string, bool>("Brevity is the soul of wit", false));
            data.Add(new KeyValuePair<string, bool>("...type your own saying", true));
        }
        private void colorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (colorDialog1.ShowDialog() == DialogResult.OK)
                label1.ForeColor = colorDialog1.Color;
        }
        private void fontToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (fontDialog1.ShowDialog() == DialogResult.OK)
                label1.Font = fontDialog1.Font;
        }
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            KeyValuePair<string, bool> val = (KeyValuePair<string, bool>)(sender as ComboBox).SelectedItem;
            if (val.Value)
            {
                AddSaying form = new AddSaying();
                if (form.ShowDialog() == DialogResult.OK)
                    data.Insert(data.Count - 1, new KeyValuePair<string, bool>(form.Value, false));
            }
        }
    }
}


http://www.AssignmentExpert.com/

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS