ribbonControl

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ribbonControl相关的知识,希望对你有一定的参考价值。

http://blog.csdn.net/archielau/article/details/37544251

//1.窗体Devexpress风格
namespace FrmMain
{
    public partial class FrmMain : DevExpress.XtraBars.Ribbon.RibbonForm
    {

    }
}

ribbonControl添加动态皮肤

1.添加引用DevExpress.UserSkins.BonusSkins

2.拖入控件ribbonControl1,添加分组,ribbonPageGroup1,添加ribbonGalleryBarItem1

        private void FrmSuprMain_Load(object sender, EventArgs e)
        {
            //皮肤
            DevExpress.UserSkins.BonusSkins.Register();
            DevExpress.Skins.SkinManager.EnableFormSkins();
            DevExpress.XtraBars.Helpers.SkinHelper.InitSkinGallery(ribbonGalleryBarItem1, true);
            CheckFile();//检查文件
            GetXmlSkin();//获取xml主题
        }

        #region 检查XML文件是否存在
        public void CheckFile()
        {
            try
            {
                if (System.IO.File.Exists("SkinInfo.xml") == false)
                {
                    //XtraMessageBox.Show("不存在XML");
                    CreateXml();
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        #region 创建XML文件

        public void CreateXml()
        {
            XmlDocument doc = new XmlDocument();
            //建立xml定义声明
            XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);
            doc.AppendChild(dec);

            //创建根节点
            XmlElement root = doc.CreateElement("SetSkin");
            XmlElement rootone = doc.CreateElement("Skinstring");//皮肤


            //将one,two,插入到root节点下
            doc.AppendChild(root);
            root.AppendChild(rootone);
            doc.Save("SkinInfo.xml");
        }

        #endregion

        #region 读取Xml节点内容

        public void GetXmlSkin()
        {
            try
            {
                XmlDocument mydoc = new XmlDocument();
                mydoc.Load("SkinInfo.xml");
                XmlNode ressNode = mydoc.SelectSingleNode("SetSkin");
                DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(ressNode.SelectSingleNode("Skinstring").InnerText);
          

            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        #endregion

        #endregion

 

 

        private void ribbonGalleryBarItem1_GalleryItemClick(object sender, DevExpress.XtraBars.Ribbon.GalleryItemClickEventArgs e)
        {
            string name = string.Empty;
            string caption = string.Empty;
            if (ribbonGalleryBarItem1.Gallery == null) return;
            caption = ribbonGalleryBarItem1.Gallery.GetCheckedItems()[0].Caption;//主题的描述
            caption = caption.Replace("主题:", "");
            ribbonGalleryBarItem1.Caption = "主题:" + caption;
            XmlDocument doc = new XmlDocument();
            doc.Load("SkinInfo.xml");
            XmlNodeList nodelist = doc.SelectSingleNode("SetSkin").ChildNodes;
            foreach (XmlNode node in nodelist)
            {
                XmlElement xe = (XmlElement)node;//将子节点类型转换为XmlElement类型 
                if (xe.Name == "Skinstring")
                {
                    xe.InnerText = caption;
                }
            }

            doc.Save("SkinInfo.xml");
        }

 

 

 

barButtonItem

LargeGlyph设置图片即可显示

Glyph:属性设置图片

RibbonStyle:属性设置为Large

以上是关于ribbonControl的主要内容,如果未能解决你的问题,请参考以下文章

ribbonControl

DevExpress中RibbonControl的简单应用

dotnetbar ribbonControl中按钮下拉菜单的问题

RibbonContrl 画背景图片

微信小程序代码片段

VSCode自定义代码片段——CSS选择器