Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ComBox"></param>
        /// <param name="SelVal"></param>
        private void SelectedComboBoxItemByValue(ComboBox ComBox, string SelVal)
        {
            if (ComBox.Items != null && ComBox.Items.Count > 0)
            {
                Utility.ComBox.ComboBoxItem comBoxItem = null;
                try
                {
                    for (int i = 0; i < ComBox.Items.Count; i++)
                    {
                        comBoxItem = (Utility.ComBox.ComboBoxItem)ComBox.Items[i];

                        if (comBoxItem.Value.ToString() == SelVal)
                        {
                            ComBox.SelectedIndex = i; break;
                        }
                    }
                }
                catch (System.Exception ex)
                {
                    this.ERROR(ex.Message, true);
                }
                finally
                {
                    if (comBoxItem != null)
                    {
                        comBoxItem = null;
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        private void InitializeInfo()
        {
            this.comBoxSettingList.Items.Clear();

            Utility.ComBox.ComboBoxItem comBoxItem = null;
            try
            {
                string value = string.Empty;

                IEnumerable <XElement> xElItems =
                    from el in XDoc.Root.Elements("Item")
                    select el;

                if (xElItems.Any())
                {
                    int i = 0;

                    foreach (XElement item in xElItems)
                    {
                        string selected = item.Attribute(XmlSetting.ColumnName.Columns.Selected) != null?item.Attribute(XmlSetting.ColumnName.Columns.Selected).Value : string.Empty;

                        value = item.Element(XmlSetting.ColumnName.Columns.Caption).Value;

                        comBoxItem = new Utility.ComBox.ComboBoxItem();

                        comBoxItem.Text = value;

                        comBoxItem.Value = i;

                        comBoxItem.ForeColor = selected == "Y" ? Color.Blue : Color.Red;

                        this.comBoxSettingList.Items.Add(comBoxItem);

                        if (selected == "Y")
                        {
                            this.comBoxSettingList.SelectedIndex = i;
                        }

                        i++;
                    }
                }
            }
            catch (System.Exception ex)
            {
                this.ERROR(ex.Message, true);
            }
            finally
            {
                if (comBoxItem != null)
                {
                    comBoxItem = null;
                }
            }
        }