DevExpress是非常主流的.NET控件,眼下全世界和中国都用非常多用户使用,只是因为是英文版,初次接触的同学可能会认为困难。这里就总结DevExpress常见的10个使用技巧。



1.TextEditor(barEditItem)取文本 



string editValue = barEditItem1.EditValue.ToString();    //错误,返回null



string editValue = ((DevExpress.XtraEditors.TextEdit)barEditItem).EditValue.ToString();    //精确,返回文本框内容 DevExpress使用技巧



2.ComboBoxEdit(barEditItem)加入Item 




string item = "comboboxItem1";

((DevExpress.XtraEditors.Repository.RepositoryItemComboBox)this.barEditItem.Edit).Items.Add(item);



3.ComboBoxEdit(barEditItem)取文本 



string itemValue = this.barEditItem.EditValue.ToString();



4.Ribbon控件 



//加入Page

DevExpress.XtraBars.Ribbon.RibbonPage ribbonPage = new RibbonPage();

ribbonControl.Pages.Add(ribbonPage);

//加入Group

DevExpress.XtraBars.Ribbon.RibbonPageGroup ribbonPageGroup = new RibbonPageGroup();

ribbonPage.Groups.Add(ribbonPageGroup);

//加入Button

DevExpress.XtraBars.BarButtonItem barButtonItem = new BarButtonItem();

ribbonPageGroup.ItemLinks.Add(barButtonItem);

//加入barSubItem

DevExpress.XtraBars.BarSubItem barSubItem = new BarSubItem();

ribbonPageGroup.ItemLinks.Add(barSubItem);

//barSubItem下加入Button

barSubItem.AddItem(barButtonItem);





//神秘的删除Page问题( DevExpress使用技巧)

while (this.ribbonControl.Pages.Count > 0)

{

ribbonControl.Pages.Remove(ribbonControl.Pages[0]);    //调试正常。运转报异常

}

while (this.ribbonControl.Pages.Count > 0)

{

ribbonControl.SelectedPage = ribbonControl.Pages[0];

ribbonControl.Pages.Remove(ribbonControl.SelectedPage); //运转正常

}

//遏止F10键Tips (DevExpress使用技巧)

ribbonControl.Manager.UseF10KeyForMenu = false;

//DXbutton

ApplicationIcon属性修改图标

右键 Add ApplicationMenu 加入evExpress.XtraBars.Ribbon.ApplicationMenu5.HitInfo 



//在Tab页上点击右键的工作响应(DevExpress使用技巧)

void xtraTabbedMdiManager_Event(object sender, MouseEventArgs e)

{

if (e.Button == MouseButtons.Right && ActiveMdiChild != null)

{

DevExpress.XtraTab.ViewInfo.BaseTabHitInfo hInfo = xtraTabbedMdiManager.CalcHitInfo(e.Location);

//右键点击位置:在Page上且不在封闭button内

if (hInfo.IsValid && hInfo.Page != null && !hInfo.InPageCloseButton)

{

this.popupMenu.ShowPopup(Control.MousePosition);//在鼠标位置弹出,而不是e.Location

}

}

}

//在ribbon上点击右键的工作响应

private void ribbonControl1_ShowCustomizationMenu(object sender, RibbonCustomizationMenuEventArgs e)

{

//禁掉原系统右键菜单

e.ShowCustomizationMenu = false;

//右键位置:在barButtonItem上

if (e.HitInfo != null 

&& e.HitInfo.InItem

&& e.HitInfo.Item.Item is BarButtonItem)

{

this.popupMenu.ShowPopup(Control.MousePosition);

}

//右键位置:在barSubItem中的barButtonItem上

else if (e.Link != null 

&& e.Link.Item != null 

&& e.Link.Item is BarButtonItem)

{

this.popupMenu.ShowPopup(Control.MousePosition);

}

}



6.皮肤 



//加入皮肤轨范集后注冊皮肤( DevExpress使用技巧)

DevExpress.UserSkins.OfficeSkins.Register();

DevExpress.UserSkins.BonusSkins.Register();

//设置皮肤

DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle("Liquid Sky");    //若皮肤称号错误则按系统默许设置(第一个皮肤)

//GalleryFilterMenuPopup工作设置弹出选择菜单的“All Groups”为中文

private void rgbiSkins_GalleryFilterMenuPopup(object sender, GalleryFilterMenuEventArgs e)

{

e.FilterMenu.ItemLinks[n].Caption = "一切皮肤";    //n=分组数+1

}

//GalleryInitDropDownGallery工作设置弹出皮肤列表的表头“ALL Groups”为中文

private void rgbiSkins_GalleryInitDropDownGallery(object sender, InplaceGalleryEventArgs e)

{

e.PopupGallery.FilterCaption = "一切皮肤";

}



7.dockManager 



将视图的状况信息保管到xml文件

dockManager1.SaveLayoutToXml("..\\UserConfig\\ViewInfo.xml");

导出xml中保管的状况信息

dockManager1.RestoreLayoutFromXml("..\\UserConfig\\ViewInfo.xml");



8.barManager 



设置bar的字体与系统字体

barAndDockingController1.AppearancesBar.ItemsFont = new Font(this.Font.FontFamily, currentFontSize);



9.设置系统字体 



DevExpress.Utils.AppearanceObject.DefaultFont = new Font(this.Font.FontFamily, currentFontSize);



10.treeView 



为tree节点加右键菜单并选中该节点

private void treeList1_MouseDown(object sender, MouseEventArgs e)

{

if (e.Button == MouseButtons.Right)

{

DevExpress.XtraTreeList.TreeListHitInfo hi = treeList1.CalcHitInfo(e.Location);

if (hi.Node != null && hi.Node.ImageIndex == 5) //叶子节点的ImageIndex == 5

{

TreeListNode node = treeList1.FindNodeByID(hi.Node.Id);

treeList1.FocusedNode = node;



this.popupMenu1.ShowPopup(MousePosition);

}

}

}

DevExpress 控件使用技巧的更多相关文章

  1. DEVEXPRESS控件使用技巧记录-GRIDCONTROL

    1. 存在父子表的时候,只允许父表的一条记录展开,其他记录都收起 方法:Feature Browser -> Master-Detail -> behavior -> AllowOn ...

  2. DevExpress控件的GridControl控件小结

    DevExpress控件的GridControl控件小结 (由于开始使用DevExpress控件了,所以要点滴的记录一下) 1.DevExpress控件组中的GridControl控件不能使横向滚动条 ...

  3. DevExpress控件安装、汉化使用教程

    前言 DevExpress是一个庞大的控件库,也很是好用(没用过,听说),但是要收费. 网上关于DevExpress的教程满天飞,我找了一下午也没找到正确的安装.简单实用教程,还是自己摸索吧. 自己动 ...

  4. FastReport报表控件使用技巧总结

    FastReport报表控件使用技巧总结 1.FastReport中如何访问报表中的对象? 可以使用FindObject方法. TfrxMemoView(frxReport1.FindObject(' ...

  5. 在Winform开发框架中,利用DevExpress控件实现数据的快速录入和选择

    在实际的项目开发过程中,有好的控件或者功能模块,我都是想办法尽可能集成到我的WInform开发框架中,这样后面开发项目起来,就可以节省很多研究时间,并能重复使用,非常高效方便.在我很早之前的一篇博客& ...

  6. DevExpress控件使用经验总结- GridView列表行号显示操作

    DevExpress是一个比较有名的界面控件套件,提供了一系列的界面控件套件的DotNet界面控件.本文主要介绍我在使用DevExpress控件过程中,遇到或者发现的一些问题解决方案,或者也可以所示一 ...

  7. DevExpress控件开发常用要点(项目总结版)

    使用DevExpress控件来做项目开发已经有很长一段时间了,在摸索开发到客户苛刻要求的过程中,其中碰到过很多问题需要解决的,随着一个个问题的解决,也留下很多对DevExpress控件的使用经验及教训 ...

  8. DevExpress控件-- Gridcontrol合并表头

    写在前面的话: 在园子里逛了有一段时间了,一直想写点东西,但苦于自己的水平有限,生怕写出来的东西浪费了读者的时间.楼主有幸参加了公司DevExpress控件的培训,独乐乐不如众乐乐,特附上Demo以飨 ...

  9. DevExpress控件-GridControl根据条件改变单元格/行颜色--转载

    DevExpress控件-数据控件GridControl,有时我们需要根据特定条件改变符合条件的行或者单元格颜色达到突出显示目的,现在动起鼠标跟我一起操作吧,对的,要达到这个目的您甚至都不用动键盘. ...

随机推荐

  1. vue - webpack.base.conf.js

    描述:webapck基本配置文件. 为了给开发文件和打包文件(webpack.dev.conf.js|| webpack.prod.conf.js) 提供方便. 'use strict' // 路径 ...

  2. 运行maven pom.xml文件后编译环境变为jdk1.5

    idea中运行pom.xml文件后,将编译环境变成了1.5,造成一系列的编译问题很是不方便. 以下是解决方法: 在"pom.xml"里加入如下代码: <properties& ...

  3. mui ajax方法

    mui ajax方法详解: mui提供了mui.ajax,在此基础上有分装出mui.get()/mui.getJSON()/mui.post()三个方法. mui.ajax( url [,settin ...

  4. JDBC 使用SimpleJdbcTemplate实现Dao

    public interface UserDao {     public void addUser(User user);     public User getUser(int userId); ...

  5. log4j 配置(转)

    log4j是干什么的 log4j是Apache的一个开源项目,主要功能是打印日志信息,以各种形式在各种地方花式打印日志. 使用log4j的准备工作 使用log4j就必须要引入其jar包.附上官网地址h ...

  6. Mac 下安装Ruby环境(转)

    步骤1 - 安装 RVM RVM 是干什么的这里就不解释了,后面你将会慢慢搞明白. $ curl -L https://get.rvm.io | bash -s stable 期间可能会问你sudo管 ...

  7. sql 语句中 id&lt ;SELECT * FROM t_blog WHERE id&lt;#{id} ORDER BY id DESC LIMIT 1

  8. Bash中的空格

    空格,一个看不见的字符,很不起眼,很多人经常忽略它,导致代码出错,却还找不着北. 先了解下bash中什么时候该用空格,什么时候不该用. . 等号赋值两边不能有空格 . 命令与选项之间需要空格 . 管道 ...

  9. Atitit JAVA p2p设计与总结  JXTA 2

    Atitit JAVA p2p设计与总结  JXTA 2 JXTA 2 是开放源代码 P2P 网络的第二个主要版本,它利用流行的.基于 Java 的参考实现作为构建基础.在设计方面进行了重要的修改,以 ...

  10. python学习之with...as语句

    python中的with...as...语句类似于try...finally...语句: # -*- coding: utf-8 -*- # """ with...as. ...