コード例 #1
0
ファイル: ViewShippers.cs プロジェクト: HeleneD/CCTB-445
        private void PopulateShippersComboBox()
        {
            NorthwindManager manager = new NorthwindManager();
            var data = manager.ListShippers();

            data.Insert(0, new Shipper()
            {
                ShipperID = -1, CompanyName = "[select a shipper]"
            });
            cboShippers.DataSource    = data;
            cboShippers.DisplayMember = "CompanyName"; // Co Name is a property on shiper entity"
            cboShippers.ValueMember   = "ShipperID";   // Shipper id is th property that repr primary key unique id
            //cboShippers.Items.Insert(0, "[select a shipper]");
            cboShippers.SelectedIndex = 0;             // first item in the combo box
        }
コード例 #2
0
        private void PopulateShippersComboBox()
        {
            NorthwindManager manager = new NorthwindManager();
            var data = manager.ListShippers();

            // Use a "fake" data item at the top of the list for the message
            data.Insert(0, new Shipper()
            {
                ShipperID = -1, CompanyName = "[Select a Shipper]"
            });
            cboShippers.DataSource    = data;
            cboShippers.DisplayMember = "CompanyName"; // CompanyName is a property of the Shipper class
            cboShippers.ValueMember   = "ShipperID";   // ShipperID is the property that represents the Primary Key
            cboShippers.SelectedIndex = 0;             // the first item in the ComboBox
        }
コード例 #3
0
ファイル: ViewShippers.cs プロジェクト: csjawahar/CCTB-445
        private void PopulateShippersComboBox()
        {
            NorthwindManager nwm = new NorthwindManager();
            var data             = nwm.ListShippers();

            data.Insert(0, new Shipper()
            {
                ShipperID = -1, CompanyName = "[select a shipper]"
            });
            cboShippers.DataSource    = data;
            cboShippers.DisplayMember = "CompanyName";
            cboShippers.ValueMember   = "ShipperID";
            //cboShippers.Items.Insert(0, "[select a shipper]");
            cboShippers.SelectedIndex = 0; //the first in the  cbo list
        }
コード例 #4
0
        private void PopulateShippersComboBox()
        {
            NorthwindManager manager = new NorthwindManager();
            var data = manager.ListShippers();

            //Use a 'fake' data item at top of list for the message
            data.Insert(0, new Shipper()
            {
                ShipperID = -1, CompanyName = "[Select a Shipper]"
            });
            cboShippers.DataSource    = data;
            cboShippers.DisplayMember = "CompanyName";
            cboShippers.ValueMember   = "ShipperID";
            //cboShippers.Items.Insert(0, "[Select a Shipper]");
            cboShippers.SelectedIndex = 0; //first item in the combobox
        }
コード例 #5
0
ファイル: ViewShippers.cs プロジェクト: hoangker/CCTB-445
        private void PopulateShippersComboBox()
        {
            NorthwindManager manager = new NorthwindManager();
            var data = manager.ListShippers();

            data.Insert(0, new Shipper()
            {
                ShipperID   = -1,
                CompanyName = "[Select a shipper]"
            });
            cboShippers.DataSource    = data;
            cboShippers.DisplayMember = "CompanyName"; // CompanyName is a property of the Shipper class
            cboShippers.ValueMember   = "ShipperID";   // ShipperID is the property that represents the Primary Key (uniquely distinguishes each shipper in the database)
            //cboShippers.Items.Insert(0, "[Select a shipper]");
            cboShippers.SelectedIndex = 0;
        }
コード例 #6
0
ファイル: ViewShippers.cs プロジェクト: ddbar/june12
        private void ViewShippers_Load(object sender, EventArgs e)
        {
            // try and catch error
            NorthwindManager manager = new NorthwindManager();
            var data = manager.ListShippers();

            // use a fake data item at the top of list the messsage
            data.Insert(0, new Shipper()
            {
                ShipperID = -1, CompanyName = "[select a shipper]"
            });
            cboShippers.DataSource    = data;
            cboShippers.DisplayMember = "CompanyName"; // CompanyName is a property of
            // the Shipper class
            cboShippers.ValueMember = "ShipperID";     // ShipperID is the property that
            // represents the Primary key (uniquely distinguishes each shipper in the database)

            cboShippers.SelectedIndex = 0; // the first item in the combo box
        }