Пример #1
0
        /// <summary>
        /// bind ข้อมูลสำหรับ ComboBox
        /// </summary>
        /// <param name="cmbTarget"></param>
        /// <param name="dt"></param>
        /// <param name="displayMember"></param>
        /// <param name="valueMember"></param>
        public static void BindComboBox(System.Windows.Forms.ComboBox cmbTarget, DataTable dt, string displayMember, string valueMember)
        {
            try
            {
                cmbTarget.DataSource = null;
                cmbTarget.Items.Clear();

                if (dt.Rows.Count > 0)
                {
                    cmbTarget.DataSource = null;
                    cmbTarget.BeginUpdate();
                    cmbTarget.DisplayMember = displayMember;
                    cmbTarget.ValueMember   = valueMember;
                    cmbTarget.DataSource    = dt;
                    cmbTarget.EndUpdate();
                    cmbTarget.SelectedIndex = -1;
                }
                else
                {
                    cmbTarget.Items.Add("---- ไม่พบข้อมูล -----");
                    cmbTarget.SelectedIndex = 0;
                }
            }
            catch
            {
                throw;
            }
        }
Пример #2
0
        public override bool Init()
        {
            // load analyzers
            try
            {
                Type[] analyzerTypes =
                    LukeNet.ClassFinder.ClassFinder.GetInstantiableSubtypes(typeof(Analyzer));
                if (analyzerTypes == null || analyzerTypes.Length == 0)
                {
                    // using default
                    foreach (Type t in defaultAnalyzers)
                    {
                        analyzers[t.FullName] = t;
                    }
                }
                else
                {
                    foreach (Type aType in analyzerTypes)
                    {
                        analyzers[aType.FullName] = aType;
                    }
                }
            }
            catch (Exception) {}

            cmbAnalyzers.BeginUpdate();
            cmbAnalyzers.Items.Clear();

            string[] aNames = new String[analyzers.Count];
            analyzers.Keys.CopyTo(aNames, 0);
            cmbAnalyzers.Items.AddRange(aNames);
            cmbAnalyzers.EndUpdate();

            return(true);
        }
Пример #3
0
 public static void BindListToCombobox(object _list, System.Windows.Forms.ComboBox cmb, string DisplayMember, string ValueMember)
 {
     cmb.BeginUpdate();
     cmb.DataSource    = _list;
     cmb.DisplayMember = DisplayMember;
     cmb.ValueMember   = ValueMember;
     cmb.EndUpdate();
 }
Пример #4
0
 public void FillMonths(System.Windows.Forms.ComboBox comboBox)
 {
     comboBox.BeginUpdate();
     comboBox.Items.Clear();
     System.Globalization.DateTimeFormatInfo dFi = InfoApp.DTFormatInfo;
     comboBox.Items.AddRange(dFi.MonthNames);
     comboBox.Items.Remove("");
     comboBox.SelectedIndex = System.DateTime.Today.Month - 1;
     comboBox.EndUpdate();
 }
Пример #5
0
 public static void BindEntityToCombobox(object ent, System.Windows.Forms.ComboBox cmb, string DisplayMember, string ValueMember, string Text)
 {
     if (ent != null)
     {
         cmb.BeginUpdate();
         cmb.DataSource    = ent;
         cmb.DisplayMember = DisplayMember;
         cmb.ValueMember   = ValueMember;
         cmb.EndUpdate();
     }
 }
 private void InitializeSaveDataType()
 {
     CBox_SaveDataType.BeginUpdate();
     {
         foreach (SaveDataType type in Enum.GetValues(typeof(SaveDataType)))
         {
             CBox_SaveDataType.Items.Add(new CBoxItem_SaveDataType(type));
         }
     }
     CBox_SaveDataType.EndUpdate();
 }
Пример #7
0
 public static void InitComboBox(System.Windows.Forms.ComboBox box, Altaxo.Collections.SelectableListNodeList names)
 {
     box.BeginUpdate();
     box.Items.Clear();
     foreach (Altaxo.Collections.SelectableListNode node in names)
     {
         box.Items.Add(node);
     }
     foreach (Altaxo.Collections.SelectableListNode node in names)
     {
         if (node.Selected)
         {
             box.SelectedItem = node;
             break;
         }
     }
     box.EndUpdate();
 }
Пример #8
0
        public static void BindDataTableToCombobox(DataTable dt, System.Windows.Forms.ComboBox cmb, string DisplayMember, string ValueMember, string Text)
        {
            if (dt.Rows.Count > 0)
            {
                dt.Columns[DisplayMember].MaxLength = 100;

                DataRow dr = dt.NewRow();
                //dr[0] = Text;
                dr[DisplayMember] = Text;

                dt.Rows.InsertAt(dr, 0);

                cmb.BeginUpdate();
                cmb.DataSource    = dt;
                cmb.DisplayMember = DisplayMember;
                cmb.ValueMember   = ValueMember;
                cmb.EndUpdate();
            }
        }
Пример #9
0
        private void UpdateTaskList(Timer timer)
        {
            if (timer == null)
            {
                return;
            }
            StringList tasks = timer.GetTaskList();

            cboTasks.BeginUpdate();
            cboTasks.Items.Clear();
            cboTasks.Items.AddRange(tasks.ToArray());
            if (tasks.Count > 0)
            {
                cboTasks.Text = tasks[tasks.Count - 1];
            }
            else
            {
                cboTasks.Text = "";
            }
            cboTasks.EndUpdate();
        }
Пример #10
0
        public static void BindDataTableToCombobox(DataTable dt, System.Windows.Forms.ComboBox cmb, string DisplayMember, string ValueMember)
        {
            cmb.DataSource = null;
            cmb.Items.Clear();

            if (dt.Rows.Count > 0)
            {
                cmb.DataSource = null;
                cmb.BeginUpdate();
                cmb.DisplayMember = DisplayMember;
                cmb.ValueMember   = ValueMember;
                cmb.DataSource    = dt;
                cmb.EndUpdate();
                // cmb.SelectedIndex = -1;
            }
            else
            {
                //cmbTarget.Items.Add("---- ไม่พบข้อมูล -----");
                cmb.Items.Add("");
                cmb.SelectedIndex = 0;
            }
        }