zoukankan      html  css  js  c++  java
  • DevExpress02、RibbonControl

    RibbonControl

    image

    常用操作

    1、如何代码显示选中的页

    ribbonControl1.SelectedPage = ribbonPage2;

    2、如何绑定ApplicationMenus和PopupMenu:

              通过ribbonControl上的PopupContextMenu进行绑定;


    如何代码创建RibbonContrl

    效果如下:


    代码如下:

    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;
    
    using DevExpress.XtraBars.Ribbon;
    
    using DevExpress.XtraBars;
    
    namespace DXApplication_1
    {
        public partial class RibbonCtrolForm2 : DevExpress.XtraEditors.XtraForm
        {
            public RibbonCtrolForm2()
            {
                InitializeComponent();
            }
    
            private void RibbonCtrolForm2_Load(object sender, EventArgs e)
            {
                // Create a RibbonControl
    
                RibbonControl RibbonControl = new RibbonControl();
    
                this.Controls.Add(RibbonControl);
    
                // Assign the image collection that will provide images for bar items.
    
                RibbonControl.Images = imageCollection1;
                
                // Create a Ribbon page.
                RibbonPage page1 = new RibbonPage("Home");
    
                // Create a Ribbon page group.
                RibbonPageGroup group1 = new RibbonPageGroup("File");
                // Create another Ribbon page group.
                RibbonPageGroup group2 = new RibbonPageGroup("File 2");
                
                // Create a button item using the CreateButton method.
                // The created item is automatically added to the item collection of the RibbonControl.
                BarButtonItem itemOpen = RibbonControl.Items.CreateButton("Open...");
                itemOpen.ImageIndex = 4;
                itemOpen.ItemClick += new ItemClickEventHandler(itemOpen_ItemClick);
                
                // Create a button item using its constructor.
                // The constructor automatically adds the created item to the RibbonControl's item collection.
                BarButtonItem itemClose = new BarButtonItem(RibbonControl.Manager, "Close");
                itemClose.ImageIndex = 3;
                itemClose.ItemClick += new ItemClickEventHandler(itemClose_ItemClick);
    
    
    
                // Create a button item using the default constructor.
                BarButtonItem itemPrint = new BarButtonItem();
                // Manually add the created item to the item collection of the RibbonControl.
                RibbonControl.Items.Add(itemPrint);
                itemPrint.Caption = "Search";
                itemPrint.ImageIndex = 2;
                itemPrint.ItemClick += new ItemClickEventHandler(itemPrint_ItemClick);
    
    
    
                // Add the created items to the group using the AddRange method. 
                // This method will create bar item links for the items and then add the links to the group.
                group1.ItemLinks.AddRange(new BarItem[] { itemOpen, itemClose, itemPrint });
                // Add the Open bar item to the second group.
                group2.ItemLinks.Add(itemOpen);
    
                // Add the created groups to the page.
                page1.Groups.Add(group1);
                page1.Groups.Add(group2);
    
                // Add the page to the RibbonControl.
                RibbonControl.Pages.Add(page1);
            }
    
            void itemPrint_ItemClick(object sender, ItemClickEventArgs e)
            {
            }
    
            void itemClose_ItemClick(object sender, ItemClickEventArgs e)
            {
            }
    
            void itemOpen_ItemClick(object sender, ItemClickEventArgs e)
            {
            }
        }
    }
  • 相关阅读:
    javablogs
    Android学习笔记WIFI设备
    线程
    初次尝试Chrome扩展开发——以幻灯片方式显示网页内的图片
    could not find the main class, Program will exit(已解决)
    tomcat6.0配置(含配置视频下载)
    Windows下JDK1.6.0+Tomcat6.0的安装配置
    Java学习
    【翻译】在没有安装ASP.NET MVC3的服务器上运行ASP.NET MVC3的程序scottgu
    AForge.NET框架的使用
  • 原文地址:https://www.cnblogs.com/springsnow/p/10216725.html
Copyright © 2011-2022 走看看