Ejemplo n.º 1
0
        private void listViewComplex_CellEditStarting(object sender, CellEditEventArgs e)
        {
            // We only want to mess with the Cooking Skill column
            if (e.Column.Text != "Cooking skill")
            {
                return;
            }

            Person   personBeingEdited = (Person)e.RowObject;
            ComboBox cb = new ComboBox();

            cb.Bounds        = e.CellBounds;
            cb.Font          = ((ObjectListView)sender).Font;
            cb.DropDownStyle = ComboBoxStyle.DropDownList;
            cb.Items.AddRange(new object[] { "Pay to eat out", "Suggest take-away", "Passable", "Seek dinner invitation", "Hire as chef" });
            cb.SelectedIndex         = Math.Max(0, Math.Min(cb.Items.Count - 1, ((int)e.Value) / 10));
            cb.SelectedIndexChanged += delegate(object o, EventArgs args) {
                personBeingEdited.CulinaryRating = cb.SelectedIndex * 10;
            };
            ControlUtilities.AutoResizeDropDown(cb);

            e.Control = cb;
        }