Example Application: Movie Review



A domain up/down control is a spin button that is used to navigate a list of values or objects. This application shows how to visit the members of an array, retrieve its members and display their values.


ApplicationApplication: Introducing the Domain Up-Down Control

  1. Start a new Windows Application and name it MovieReview1
  2. Right-click each of the following pictures and paste them in the MovieReview1\MovieReview1\bin\Debug folder of the current project
  3. Design the form as follows:
    Movie Review
    Control Text Name Other Properties
    Label Title:    
    DomainUpDown   dudTitles TextAlign: Center
    UpDownAlign: Left
    Label Director:    
    TextBox   txtDirector  
    Label Cast of Characters    
    Label © Year    
    TextBox   txtYearReleased TextAlign: Right
    Label Rating:    
    TextBox   txtRating  
    ListBox   lbxCastMembers  
    Label Length:    
    TextBox   txtLength  
    PictureBox   pbxImage  
    Button Close btnClose  
  4. In the Solution Explorer, right-click Form1.cs and click Rename
  5. Type MovieReview.cs and press Enter
  6. Double-click an unoccupied area of the form
  7. Return to the form
  8. On the form, double-click the domain up-down control
  9. Implement its events as follows:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    namespace MovieReview1
        public partial class MovieReview : Form
            string[] Titles        = new string[8];
            string[] Directors     = new string[8];
            int[]    YearsReleased = new int[8];
            string[] Ratings       = new string[8];
            string[] Lengths       = new string[8];
            string[] Pictures      = new string[8];
            ListBox[] Actors = new ListBox[8];
            public MovieReview()
            private void MovieReview_Load(object sender, EventArgs e)
                Titles[0] = "Distinguished Gentleman (The)";
                Directors[0] = "Jonathan Lynn";
                YearsReleased[0] = 1992;
                Ratings[0] = "R";
                Lengths[0] = "112 Minutes";
                Pictures[0] = "distgent.jpg";
                Actors[0] = new ListBox();
                Actors[0].Items.Add("Eddie Murphy");
                Actors[0].Items.Add("Lane Smith");
                Actors[0].Items.Add("Sheryl Lee Ralph");
                Actors[0].Items.Add("Joe Don Baker");
                Actors[0].Items.Add("Victoria Rowell");
                Actors[0].Items.Add("Grant Shaud");
                Actors[0].Items.Add("Kevin McCarthy");
                Actors[0].Items.Add("Charles S. Dutton");
                Actors[0].Items.Add("Victor Rivers");
                Actors[0].Items.Add("Chi McBride");
                Actors[0].Items.Add("Sonny Jim Gaines");
                Actors[0].Items.Add("Noble Willingham");
                Actors[0].Items.Add("Gary Frank");
                Actors[0].Items.Add("Daniel Benzali");
                Actors[0].Items.Add("Cynthia Harris");
                Titles[1] = "Fatal Attraction";
                Directors[1] = "Adrian Lyne";
                YearsReleased[1] = 1987;
                Ratings[1] = "R";
                Lengths[1] = "119 Minutes";
                Pictures[1] = "fatal.jpg";
                Actors[1] = new ListBox();
                Actors[1].Items.Add("Michael Douglas");
                Actors[1].Items.Add("Glenn Close");
                Actors[1].Items.Add("Anne Archer");
                Actors[1].Items.Add("Ellen Hamilton Latzen");
                Actors[1].Items.Add("Stuart Pankin");
                Titles[2] = "New Jack City";
                Directors[2] = "Mario Van Peebles";
                YearsReleased[2] = 1991;
                Ratings[2] = "R";
                Lengths[2] = "97 Minutes";
                Pictures[2] = "newjack.jpg";
                Actors[2] = new ListBox();
                Actors[2].Items.Add("Wesley Snipes");
                Actors[2].Items.Add("Allen Payne");
                Actors[2].Items.Add("Chris Rock");
                Actors[2].Items.Add("Mario Van Peebles");
                Actors[2].Items.Add("Michael Michele");
                Actors[2].Items.Add("Bill Nunn");
                Titles[3] = "Showgirls";
                Directors[3] = "Paul Verhoeven";
                YearsReleased[3] = 1995;
                Ratings[3] = "NC-17";
                Lengths[3] = "128 Minutes";
                Pictures[3] = "showgirls.jpg";
                Actors[3] = new ListBox();
                Actors[3].Items.Add("Elizabeth Berkley");
                Actors[3].Items.Add("Kyle MacLachlan");
                Actors[3].Items.Add("Gina Gershon");
                Actors[3].Items.Add("Glenn Plummer");
                Titles[4] = "Annie";
                Directors[4] = "John Huston";
                YearsReleased[4] = 1982;
                Ratings[4] = "PG";
                Lengths[4] = "126 Minutes";
                Pictures[4] = "annie.jpg";
                Actors[4] = new ListBox();
                Actors[4].Items.Add("Albert Finney");
                Actors[4].Items.Add("Carol Burnett");
                Actors[4].Items.Add("Ann Reinking");
                Actors[4].Items.Add("Tim Curry");
                Actors[4].Items.Add("Bernadette Peters");
                Titles[5] = "Dave";
                Directors[5] = "Ivan Reitman";
                YearsReleased[5] = 1993;
                Ratings[5] = "R";
                Lengths[5] = "110 Minutes";
                Pictures[5] = "Dave.jpg";
                Actors[5] = new ListBox();
                Actors[5].Items.Add("Kevin Kline");
                Actors[5].Items.Add("Sigourney Weaver");
                Actors[5].Items.Add("Frank Langella");
                Actors[5].Items.Add("Kevin Dunn");
                Actors[5].Items.Add("Ving Rhames");
                Actors[5].Items.Add("Ben Kingsley");
                Actors[5].Items.Add("Charles Grodin");
                Titles[6] = "Housesitter";
                Directors[6] = "Frank Oz";
                YearsReleased[6] = 1992;
                Ratings[6] = "PG";
                Lengths[6] = "110 Minutes";
                Pictures[6] = "housesitter.jpg";
                Actors[6] = new ListBox();
                Actors[6].Items.Add("Steve Martin");
                Actors[6].Items.Add("Goldie Hawn");
                Actors[6].Items.Add("Dana Delany");
                Actors[6].Items.Add("Julie Harris");
                Actors[6].Items.Add("Donald Moffat");
                Actors[6].Items.Add("Peter MacNicol");
                Titles[7] = "Beverly Hills Cop";
                Directors[7] = "Martin Brest";
                YearsReleased[7] = 1984;
                Ratings[7] = "R";
                Lengths[7] = "105 Minutes";
                Pictures[7] = "bhc.jpg";
                Actors[7] = new ListBox();
                Actors[7].Items.Add("Eddie Murphy");
                Actors[7].Items.Add("Judge Reinhold");
                Actors[7].Items.Add("John Ashton");
                Actors[7].Items.Add("Lisa Eilbacher");
                Actors[7].Items.Add("Ronny Cox");
                Actors[7].Items.Add("Steven Berkoff");
                Actors[7].Items.Add("James Russo");
                Actors[7].Items.Add("Jonathan Banks");
                Actors[7].Items.Add("Bronson Pinchot");
                Actors[7].Items.Add("Paul Reiser");
                dudTitles.SelectedIndex = 0;
                dudTitles_SelectedItemChanged(sender, e);
    private void dudTitles_SelectedItemChanged(object sender, EventArgs e)
        txtDirector.Text = Directors[dudTitles.SelectedIndex + 1];
        txtYearReleased.Text =
                    YearsReleased[dudTitles.SelectedIndex + 1].ToString();
        txtRating.Text = Ratings[dudTitles.SelectedIndex + 1];
        txtLength.Text = Lengths[dudTitles.SelectedIndex + 1];
        pbxImage.Image =
                    Image.FromFile(Pictures[dudTitles.SelectedIndex + 1]);
        lbxCastMembers.Items.AddRange(Actors[dudTitles.SelectedIndex + 1].Items); 
  11. Return to the form
  12. Double-click the Close button and implement its event as follows:
    private void btnClose_Click(object sender, EventArgs e)
  13. Execute the application and test the domain control
  14. Close the form and return to your programming environment
  15. On the form, click the domain up-down control
  16. In the Properties window, double-click Wrap to set its value to True 
  17. Execute the application and test the domain control
  18. Close the form and return to your programming environment

Home Copyright © 2010-2015, FunctionX