zoukankan      html  css  js  c++  java
  • DevExpress控件的一些快捷操作

     用的DevExpress控件时,有一些操作并不太方便,根据我自己需要的封装了一些控件的事件,调用的时候直接绑定控件的事件就可以了

    例如:

                this.ComboBoxEdit.KeyDown += CtrlBase.ComboBoxEdit_KeyDown;
                this.LookUpEdit.KeyDown +=CtrlBase.LookUpEdit_KeyDown;
                this.TextEdit.KeyDown += CtrlBase.TextEdit_KeyDown;
                this.searchLookUpEdit.KeyDown += CtrlBase.searchLookUpEdit_KeyDown;
                this.MemoEdit.KeyDown += CtrlBase.MemoEdit_KeyDown;

    1:实现回车跳转下一个控件

        首先把需要跳转的控件的TabIndex属性设置为连续的数字,这些数字控制跳转顺序,一般都是从1开始。

        然后给控件绑定写好的事件,(如下图)就可以实现回车跳转到下一个控件

    2:实现ComboBoxEdit、LookUpEdit控件↓键调出下拉列表

      只需要给ComboBoxEdit、LookUpEdit绑定写好事件就可以实现了

    3:把绑定的事件封装在一个类里,方便下次调用

      public class CtrlBase
        {
            public static void ComboBoxEdit_KeyDown(object sender, KeyEventArgs e)
            {
                if (e.KeyCode == Keys.Enter)
                {
                    SendKeys.Send("{TAB}");  //按Enter键时调用按Tab键时候的默认方法。
                }
                if (e.KeyCode == Keys.Down)
                {
                    DevExpress.XtraEditors.ComboBoxEdit combobox = sender as DevExpress.XtraEditors.ComboBoxEdit;
                    combobox.ShowPopup();   //按↓键的时候展开下拉列表
                }
            }
            public static void TextEdit_KeyDown(object sender, KeyEventArgs e)
            {
                if (e.KeyCode == Keys.Enter)
                {
                    SendKeys.Send("{TAB}");
                }
            }
            public static void LookUpEdit_KeyDown(object sender, KeyEventArgs e)
            {
                if (e.KeyCode == Keys.Enter)
                {
                    SendKeys.Send("{TAB}");
                }
                if (e.KeyCode == Keys.Down)
                {
                    DevExpress.XtraEditors.LookUpEdit lookUp = sender as DevExpress.XtraEditors.LookUpEdit;
                    lookUp.ShowPopup();//展开下拉列表
                }
            }
            public static void searchLookUpEdit_KeyDown(object sender, KeyEventArgs e)
            {
                if (e.KeyCode == Keys.Enter)
                {
                    SendKeys.Send("{TAB}");
                }
            }
            public static void MemoEdit_KeyDown(object sender, KeyEventArgs e)
            {
                if (e.KeyCode == Keys.Down)
                {
                    SendKeys.Send("{TAB}");//↓键
                }
            }
        }
  • 相关阅读:
    700. Search in a Binary Search Tree
    100. Same Tree
    543. Diameter of Binary Tree
    257. Binary Tree Paths
    572. Subtree of Another Tree
    226. Invert Binary Tree
    104. Maximum Depth of Binary Tree
    1、解决sublime打开文档,出现中文乱码问题
    移植seetafaceengine-master、opencv到ARM板
    ubuntu16.04-交叉编译-SeetaFaceEngine-master
  • 原文地址:https://www.cnblogs.com/zhangjd/p/5161561.html
Copyright © 2011-2022 走看看