示例#1
0
        public void SetControlValue(string digit)
        {
            Control ctrl = EditControl;

            #region Validation
            if (!EnableKey)
            {
                return;
            }
            if (EnableActiveControl)
            {
                Form frm = GetParentForm();
                if (frm != null)
                {
                    ctrl = frm.ActiveControl;
                    if (ctrl.Parent is BaseEdit)
                    {
                        ctrl = ctrl.Parent;
                    }
                    if (ctrl != EditControl)
                    {
                        if (!(ctrl is BaseEdit) || ((ctrl is BaseEdit) && ((BaseEdit)ctrl).Properties.ReadOnly))
                        {
                            ctrl = EditControl; // Контрол олдоогүй Дефаулт контролоо авах
                            if (ctrl != null)
                            {
                                ((BaseEdit)ctrl).EditValue = null;
                            }
                        }
                    }
                }
            }
            if (ctrl == null)
            {
                return;
            }
            if (!(ctrl is BaseEdit))
            {
                return;
            }
            #endregion
            #region Send key
            BaseEdit be      = (BaseEdit)(ctrl);
            char     keychar = ' ';
            switch (digit)
            {
            case "Back": keychar = '\x8'; break;

            case "CE": be.EditValue = null; break;

            default: keychar = digit[0]; break;
            }
            KeyPressEventArgs keyarg = new KeyPressEventArgs(keychar);
            be.Focus();
            be.SendKey(be, keyarg);
            #endregion
        }