zoukankan      html  css  js  c++  java
  • DevExpress09、SimpleButton、CheckButton、DropDownButton、HScrollBar控件和VScrollBar控件

    SimpleButton控件

    使用SimpleButton控件, 创建一个Button按钮,

    可以通过其Image属性添加图片;

    该控件与WinForm自带的Button按钮类似;

    效果如下:

    CheckButton 控件

    以按钮的形式显示Check 与否的操作;

    效果如下:


    代码如下:

    private void checkButton1_CheckedChanged(object sender, EventArgs e)
    {
        checkButton1.Text = checkButton1.Checked ? "Checked" : "UnChecked";
    }

    Button Style属性, 当状态发生改变时,修改其样式;

    可以在DX Image Gallery中使用自带图片,

    当Check的状态发生改变时,在事件处理代码中:

    // 改变其内部自带的图片
    this.checkButton1.Image = global::WindowsDev.Properties.Resources.clear_32x32;

    DropDownButton控件

    该控件以按钮的形式弹出上下文菜单,

    • 该控件通过DropDownControl属性绑定PopuMenu控件或PopupControlContainer控件。
    • 可以通过该控件的DropDownArrowStyle属性控制下拉箭头的显示模式,

    1. 拖一个DropDownButton

    2. 拖一个PopMenu

    3. 设置DropDownButton的DropDownControl属性为PopMenu

    4. 对PopMenu右击,进行Customize(会要求自动创建一个BarManager)

    HScrollBar控件和VScrollBar控件

    许多控件需要滚动条,像ListBoxControl、CheckedListControl控件中已经集成了滚动条,所以 就不需要另加滚动条,

    但有些控件没有集成,比如:PictureEdit控件,

    当显示的图片过长时,不能在其已有的区域显示,

    就需要HScrollbar控件 和VScrollBar控件;


    显示效果:


    示例代码:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Linq;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using DevExpress.XtraEditors;
    
    namespace DXApplication_1
    {
        public partial class ScrollBarForm : DevExpress.XtraEditors.XtraForm
        {
            public ScrollBarForm()
            {
                InitializeComponent();
            }
    
            private void ScrollBarForm_Load(object sender, EventArgs e)
            {
                // hScrollBar
                hScrollBar1.Width = pictureBox1.Width;
                hScrollBar1.Left = pictureBox1.Left;
                hScrollBar1.Top = pictureBox1.Bottom;
                hScrollBar1.Maximum = pictureBox1.Image.Width - pictureBox1.Width;
    
                // vScrollBar
                vScrollBar1.Height = pictureBox1.Height;
                vScrollBar1.Left = pictureBox1.Left + pictureBox1.Width;
                vScrollBar1.Top = pictureBox1.Top;
                vScrollBar1.Maximum = pictureBox1.Image.Height - pictureBox1.Height;
            }
    
            int tmpX = 0;
            private void hScrollBar1_Scroll(object sender, ScrollEventArgs e)
            {
                tmpX = hScrollBar1.Value;
                pictureBox1.Refresh();
            }
    
            int tmpY = 0;
            private void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
            {
                tmpY = vScrollBar1.Value;
                pictureBox1.Refresh();
            }
    
            private void pictureBox1_Paint(object sender, PaintEventArgs e)
            {
                // draw image
                e.Graphics.DrawImage(pictureBox1.Image, e.ClipRectangle, tmpX, tmpY, e.ClipRectangle.Width, e.ClipRectangle.Height, GraphicsUnit.Pixel);
            }
        }
    }
  • 相关阅读:
    Windows Server 2003下ASP.NET无法识别IE11的解决方法
    SQL Server2005中使用XML-数据类型、查询与修改
    连接SQLServer时提示“但是在登录前的握手期间发生错误。 (provider: SSL Provider, error: 0
    无法将类型为 excel.applicationclass 的 com 强制转换为接口类型 的解决方法。
    C# WinForm使用Aspose.Cells.dll 导出导入Excel/Doc 完整实例教程
    技巧 获取电脑硬件信息 -转发
    浏览器无需下载插件 解决网页长截图的小技巧 -转发
    note 9 列表、时间复杂度、排序
    note 8 字符串
    note 7 递归函数
  • 原文地址:https://www.cnblogs.com/springsnow/p/10298873.html
Copyright © 2011-2022 走看看