Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The Premier Application You will use a Dictionary to drive this application. The Key will be the last name of the premier (there is
The Premier Application You will use a Dictionary to drive this application. The Key will be the last name of the premier (there is a method in the Premier class that generated a key) and the value will be the premier object. The images are in a folder on the p drive. The images are named also by the premier's last name. Ontario's Premiers Bob Rae Ross Whitney Hearst Drury Ferguson Henry Hepbum Conant Nixon (b. 1948) 1 October 1990-26 June 1995 Drew Kennedy Frost Robarts Davis Miller Peterson Rae You should use the file Premier.cs file. [See appendix for the logic for the Premier class] Additions to your Form1.cs file: 1. Declare a variable to store the premiers which should be declared as: Dictionary premiers. 2. Create a method InitializeGui() that will populate a Dictionary with from a List| and use the keys from the resulting dictionary to populate a ListBox. This method does the following: al a. Initialize the above variable using the following logic: This InitializeGui() method is invoke in the last line of the From1 constructor. n.k.p Winter2022 Page 2 of 4 Programming II Window Forms: PictureBox, ListBox, Dictionary Week12_Lab20 i. Initialize to an empty collection. ii. iii. Obtain a list of premier by calling the static GetPremier () of the Premier class. For each premier add a pair to the dictionary 3. The key of the pair is obtain by calling GenerateKey ( ) on the current object. The value of the pair is the current object. b. You should populate the ListBox here. This listbox contain the keys in the dictionary wwwwwwwwwwwwwwww i. Create a list from the dictionary keys, and then assign it to the DataSource property of this control. Create a UpdateGui(string key) method that will do the following: a. Retrieves the premier object based on the argument (key). b. The Name property of the above object is assigned to the Text property of the first label. c. The Life property of the above object is assigned to the Text property of the second label. d. The Start and End properties of the above object is assigned to the Text property of the third label. e. {image folder}\\key + ".jpg" will goes to the name of the image file. You need to download the zipped archive of the premier's pictures and unzip to a folder in your bin\Debug folder 4. Add a SelectedValueChanged event handler for the ListBox. This will call the previous method with the key as argument. Use the MessageBox.Show() method as a debugging tool.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Heres an approach to solve the problem Create the Dictionary In your Form1 class youve already declared a Dictionary named premiers to store the premier objects Ensure that the Premier class has a Gen...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started