Esempio n. 1
0
        public virtual void SetContrMoveNext(string strContrName, bool blPrev, int iSeed)
        {
            int index = arrContrSeq.IndexOf(strContrName);

            if (index == -1)
            {
                return;
            }
            if (!blPrev && index == arrContrSeq.Count - 1 || blPrev && index == 0)
            {
                return;
            }
            if (FocusedControl.GetType().ToString() == "DevExpress.XtraEditors.CheckedComboBoxEdit")
            {
                DevExpress.XtraEditors.CheckedComboBoxEdit cklis = FocusedControl as DevExpress.XtraEditors.CheckedComboBoxEdit;
                string   strText  = string.Empty;
                string[] arrTexts = cklis.Text.Split(",,".ToCharArray());

                foreach (CheckedListBoxItem item in cklis.Properties.Items)
                {
                    foreach (string strT in arrTexts)
                    {
                        string strTxt = strT.Trim();
                        if (strTxt == string.Empty)
                        {
                            continue;
                        }

                        if (item.Value.ToString().ToLower() == strTxt.ToLower() ||
                            item.Description.ToLower() == strTxt.ToLower())
                        {
                            strText += strText == string.Empty ? item.Value.ToString() : "," + item.Value.ToString();
                        }
                    }
                }
                cklis.EditValue = strText;
                cklis.RefreshEditValue();
            }

            int iFidx = 0;

            if (blPrev)
            {
                iFidx = index - iSeed < 0 ? 0 : index - iSeed;
            }
            else
            {
                iFidx = index + iSeed > arrContrSeq.Count - 1 ? arrContrSeq.Count - 1 : index + iSeed;
            }

            Control[] contrs = FocusedControl.Parent.Controls.Find(arrContrSeq[iFidx], false);
            if (contrs.Length <= 0)
            {
                return;
            }

            Control contr = contrs[0];

            if (contr is BaseEdit)
            {
                BaseEdit bse = contr as BaseEdit;
                if (bse.Properties.ReadOnly || !bse.Visible)
                {
                    SetContrMoveNext(arrContrSeq[iFidx], blPrev, 1);
                    return;
                }
            }
            else if (contr is ProduceManager.UcTxtPopup)
            {
                ProduceManager.UcTxtPopup bc = contr as ProduceManager.UcTxtPopup;
                if (bc.ReadOnly || !bc.Visible)
                {
                    SetContrMoveNext(arrContrSeq[iFidx], blPrev, 1);
                    return;
                }
            }
            else if (contr is ProduceManager.UcTreeList)
            {
                ProduceManager.UcTreeList bc = contr as ProduceManager.UcTreeList;
                if (bc.ReadOnly || !bc.Visible)
                {
                    SetContrMoveNext(arrContrSeq[iFidx], blPrev, 1);
                    return;
                }
            }
            switch (contr.GetType().ToString())
            {
            case "DevExpress.XtraEditors.TextEdit":
                DevExpress.XtraEditors.TextEdit txt = contr as DevExpress.XtraEditors.TextEdit;
                txt.Focus();
                txt.SelectAll();
                break;

            case "DevExpress.XtraEditors.MemoEdit":
                DevExpress.XtraEditors.MemoEdit mTxt = contr as DevExpress.XtraEditors.MemoEdit;
                mTxt.Focus();
                mTxt.SelectAll();
                break;

            case "DevExpress.XtraEditors.SimpleButton":
                DevExpress.XtraEditors.SimpleButton btn = contr as DevExpress.XtraEditors.SimpleButton;
                btn.Select();
                break;

            case "DevExpress.XtraEditors.LookUpEdit":
                DevExpress.XtraEditors.LookUpEdit dpl = contr as DevExpress.XtraEditors.LookUpEdit;
                dpl.Focus();
                dpl.ShowPopup();
                break;

            case "DevExpress.XtraEditors.CheckedComboBoxEdit":
                DevExpress.XtraEditors.CheckedComboBoxEdit ckcob = contr as DevExpress.XtraEditors.CheckedComboBoxEdit;
                ckcob.Focus();
                ckcob.SelectAll();
                break;

            case "DevExpress.XtraEditors.DateEdit":
                DevExpress.XtraEditors.DateEdit dt = contr as DevExpress.XtraEditors.DateEdit;
                dt.Focus();
                dt.Select();
                break;

            case "ExtendControl.ExtPopupTree":
                ExtendControl.ExtPopupTree ext = contr as ExtendControl.ExtPopupTree;
                ext.Focus();
                ext.ShowPopup();
                break;

            case "ProduceManager.UcTxtPopup":
                ProduceManager.UcTxtPopup ucp = contr as ProduceManager.UcTxtPopup;
                ucp.Focus();
                ucp.ShowPopup();
                break;

            case "ProduceManager.UcTreeList":
                ProduceManager.UcTreeList uct = contr as ProduceManager.UcTreeList;
                uct.Focus();
                uct.ShowPopup();
                break;

            case "DevExpress.XtraEditors.ComboBoxEdit":
                DevExpress.XtraEditors.ComboBoxEdit cob = contr as DevExpress.XtraEditors.ComboBoxEdit;
                cob.Focus();
                cob.ShowPopup();
                break;

            default:
                break;
            }
        }