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;
//DX按钮
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上且不在封闭按钮内
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  DXperience 是.NET控件套包、IDE报表生成工具和企业应用程序框架,DXperience帮助中国软件企业开发出很多优秀的软件产品 DXperience其产品的品牌、质量,是全球公认的。

本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [http://www.devexpresscn.com/]
本文地址:http://www.devexpresscn.com/news/news-88.html

DevExpress使用技巧总结的更多相关文章

  1. DevExpress 控件使用技巧

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

  2. DevExpress z

    1.TextEditor(barEditItem)取文本 string editValue = barEditItem1.EditValue.ToString();    //错误,返回null st ...

  3. DevExpress Report 其他常用设计技巧

    原文:DevExpress Report 其他常用设计技巧 1 设置默认的打印纸张及页边距 选择Report-打开属性窗口,设置默认边距(Margins)和默认纸张(PaperKind). 2 修改R ...

  4. WPF界面开发技巧大放送!DevExpress WPF格式化日期时间值

    DevExpress广泛应用于ECM企业内容管理. 成本管控.进程监督.生产调度,在企业/政务信息化管理中占据一席重要之地.通过DevExpress WPF Controls,您能创建有着强大互动功能 ...

  5. DevExpress GridControl 使用方法技巧 总结 收录整理

    一.如何解决单击记录整行选中的问题 View->OptionsBehavior->EditorShowMode 设置为:Click 二.如何新增一条记录 ().gridView.AddNe ...

  6. DevExpress使用教程:GridView经验小结(官方中文文献经典资料技巧)

    下面是笔者自己总结的使用 DevExpress Gridview 的一些经验小结,分享给大家: 1.去除 GridView 头上的 "Drag a column header here to ...

  7. [转载]DevExpress GridControl 使用方法技巧 总结 收录整理

    最近开始用DevExpress组件,发现很好的经验总结博客,在这里转载分享 原作者:https://www.cnblogs.com/wordgao/p/4517011.html 一.如何解决单击记录整 ...

  8. WPF界面开发技巧大放送!DevExpress WPF在TreeListView中扩展N级

    DevExpress广泛应用于ECM企业内容管理. 成本管控.进程监督.生产调度,在企业/政务信息化管理中占据一席重要之地.通过DevExpress WPF Controls,您能创建有着强大互动功能 ...

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

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

随机推荐

  1. java(9)并发编程

    整理自<java 并发编程的艺术> 1. 上下文切换 即使是单核处理器也支持多线程执行代码,CPU通过给每个线程分配CPU时间片来实现这个机制.时间片是CPU分配给各个线程的时间,因为时间 ...

  2. 题目1029:魔咒词典(map使用以及字符串读取函数总结)

    题目链接:http://ac.jobdu.com/problem.php?pid=1029 详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus // // ...

  3. IOS 6 和 IOS7 UITableViewCell上添加控件的获取

    假设每个cell上面都有UIButton,怎么判断哪个Cell上的按钮被按下了呢? IOS6上 -(IBAction)btnClick:(id)sender { UIButton *btn = (UI ...

  4. python nose测试框架全面介绍一

    一.简介      nose 是python自带框架unttest的扩展,使测试更简单高效:nose是一个开源的项目,可以在官网上下载源码 1.快速安装 有以下几中安装方式: easy_install ...

  5. vue--axios发送请求

    首先安装:axios $ npm install axios $ cnpm install axios //taobao源 $ bower install axios 或者使用cdn: <scr ...

  6. 推荐系统之余弦相似度的Spark实现

    推荐系统之余弦相似度的Spark实现 (1)原理分析    余弦相似度度量是相似度度量中最常用的度量关系,从程序分析中, 第一步是数据的输入, 其次是使用相似性度量公式 最后是对不同用户的递归计算. ...

  7. 1.1Tensorflow训练线性回归模型入门程序

    tensorflow #-*- coding: utf-8 -*- # @Time : 2017/12/19 14:36 # @Author : Z # @Email : S # @File : 1. ...

  8. codeforces 14A - Letter & codeforces 859B - Lazy Security Guard - [周赛水题]

    就像title说的,是昨天(2017/9/17)周赛的两道水题…… 题目链接:http://codeforces.com/problemset/problem/14/A time limit per ...

  9. 【紫书】BigInteger 高精度类型 原书上有一个bug:A+B!=B+A

    存个代码 struct BigInterger { static const int BASE = 1e8; ; vector<int> s; BigInterger() { *this ...

  10. 分治法及其python实现例子

    在前面的排序算法学习中,归并排序和快速排序就是用的分治法,分治法作为三大算法之一的,有非常多的应用例子. 分治法概念 将一个复杂的问题分成两个或更多的相同或相似的子问题,再把子问题分成更小的子问题-- ...