Пример #1
0
        /// <summary>
        /// InputComboBox에 선택된 값을 가져온다.(Invoke 아님)
        /// </summary>
        /// <param name="cmb"></param>
        /// <param name="strField"></param>
        public static string Invoke_InputComboBox_GetSelectValue(C1.Win.C1InputPanel.InputComboBox cmb, string strField)
        {
            if (cmb.SelectedIndex < 0)
            {
                return(string.Empty);
            }

            if (cmb.DataSource != null)
            {
                //DataRow dr = ((DataTable)cmb.DataSource).Select(string.Format("{0} = '{1}'", cmb.DisplayMember, cmb.Text))[0];
                return(Fnc.obj2String(((DataRowView)cmb.SelectedValue)[strField]));                              //Function.Fnc.obj2String(dr[strField]);
            }
            else
            {
                return(cmb.Text);
            }
        }
Пример #2
0
        /// <summary>
        /// InputComboBox에 string 배열의 값을 item으로 추가한다.
        /// </summary>
        /// <param name="inp"></param>
        /// <param name="cmb"></param>
        /// <param name="strItems"></param>
        /// <returns></returns>
        public static void Invoke_InputComboBox_Items_AddItems(C1InputPanel inp,
                                                               C1.Win.C1InputPanel.InputComboBox cmb, string[] strItems)
        {
            if (inp.InvokeRequired)
            {
                inp.Invoke(new delInvoke_InputComboBox_Items_AddItems(Invoke_InputComboBox_Items_AddItems), new object[] { inp, cmb, strItems });
                return;
            }

            InputOption io;

            foreach (string str in strItems)
            {
                io = new InputOption(str);
                cmb.Items.Add(io);
            }
        }
Пример #3
0
        /// <summary>
        /// InputComboBox에 string 배열의 값을 Group으로 추가한다.
        /// </summary>
        /// <param name="inp"></param>
        /// <param name="cmb"></param>
        /// <param name="strItems"></param>
        /// <returns></returns>
        public static void Invoke_InputComboBox_Items_AddGroups(C1InputPanel inp,
                                                                C1.Win.C1InputPanel.InputComboBox cmb, string[] strGroups)
        {
            if (inp.InvokeRequired)
            {
                inp.Invoke(new delInvoke_InputComboBox_Items_AddItems(Invoke_InputComboBox_Items_AddGroups), new object[] { inp, cmb, strGroups });
                return;
            }

            InputGroupHeader ig;

            foreach (string str in strGroups)
            {
                ig      = new InputGroupHeader();
                ig.Text = str;
                cmb.Items.Add(ig);
            }
        }
Пример #4
0
        /// <summary>
        /// InputComboBox에 값을 선택한다.
        /// </summary>
        /// <param name="cmb"></param>
        /// <param name="strField"></param>
        public static void Invoke_InputComboBox_SetSelectedValue(C1InputPanel inp,
                                                                 C1.Win.C1InputPanel.InputComboBox cmb, string strValue)
        {
            if (inp.InvokeRequired)
            {
                inp.Invoke(new delInvoke_InputComboBox_SetSelectedValue(Invoke_InputComboBox_SetSelectedValue), new object[] { inp, cmb, strValue });
                return;
            }

            if (cmb.DataSource != null)
            {
                foreach (DataRowView dr in ((DataTable)cmb.DataSource).DefaultView)
                {
                    if (dr[cmb.DisplayMember].ToString() == strValue)
                    {
                        cmb.SelectedValue = dr;
                        return;
                    }
                }

                cmb.SelectedIndex = -1;
            }
            else
            {
                InputOption io;
                foreach (InputComponent i in cmb.Items)
                {
                    io = i as InputOption;
                    if (io != null)
                    {
                        if (io.Text == strValue)
                        {
                            cmb.SelectedOption = io;
                            return;
                        }
                    }
                }
                cmb.SelectedIndex = -1;
            }
        }
Пример #5
0
        /// <summary>
        /// InputComboBox에 값을 선택한다.
        /// </summary>
        /// <param name="cmb"></param>
        /// <param name="strField"></param>
        public static void Invoke_InputComboBox_SetSelectedValue(C1InputPanel inp,
                                                                 C1.Win.C1InputPanel.InputComboBox cmb, string strField, string strValue)
        {
            if (inp.InvokeRequired)
            {
                inp.Invoke(new delInvoke_InputComboBox_SetSelectedValue2(Invoke_InputComboBox_SetSelectedValue), new object[] { inp, cmb, strField, strValue });
                return;
            }

            if (cmb.DataSource != null)
            {
                DataView dv;

                DataTable dt = cmb.DataSource as DataTable;


                if (dt != null)
                {
                    dv = dt.DefaultView;
                }
                else
                {
                    dv = cmb.DataSource as DataView;
                }


                foreach (DataRowView dr in dv)
                {
                    if (dr[strField].ToString().Trim() == strValue)
                    {
                        Application.DoEvents();
                        cmb.SelectedValue = dr;
                        return;
                    }
                }

                cmb.SelectedIndex = -1;
            }
        }