public static void SetControlValue(IEnumerable value, CheckedComboBox field)
        {
            if (value != null)
            {
                for (int i = 0, count = field.Items.Count; i < count; i++)
                {
                    bool valuePresent = false;
                    var listItem = ((ListItem) field.Items[i]);
                    foreach (object item in value)
                    {
                        string val = item as string;
                        if (item == null) continue;

                        if (val.Trim() == listItem.Value)
                        {
                            valuePresent = true;
                            break;
                        }
                    }

                    field.SetItemChecked(i, valuePresent);
                }
            }
            else
                for (int i = 0, count = field.Items.Count; i < count; i++)
                    field.SetItemChecked(i, false);
        }
Exemplo n.º 2
0
            // ********************************************* Construction *********************************************

            public Dropdown(CheckedComboBox ccbParent)
            {
                this.ccbParent = ccbParent;
                InitializeComponent();
                this.ShowInTaskbar = false;
                // Add a handler to notify our parent of ItemCheck events.
                this.cclb.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.cclb_ItemCheck);
            }
            // ********************************************* Construction *********************************************

            public Dropdown(CheckedComboBox ccbParent)
            {
                this.ccbParent = ccbParent;
                InitializeComponent();
                this.ShowInTaskbar = false;
                // Add a handler to notify our parent of ItemCheck events.
                this.cclb.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.cclb_ItemCheck);
            }