XtraEditors一、总体介绍
一、所有编辑器的公共功能
- 全部都可以绑定数据;
- 全部都可以独立使用或用于由 Developer Express 提供的容器控件 (XtraGrid、XtraVerticalGrid、XtraTreeList 和 XtraBars) 内的内置编辑;
- 全部都使用相同的样式、外观与感觉、以及工具提示机制,因为它们都派生于 BaseEdit 类。
要把某个特定的编辑器嵌入到容器控件中,则必须创建一个相应的 Repository 项。 Repository 项是一个组件,存储了属于某个对应编辑器的属性和事件。 容器控件使用由 repository 项提供的信息,来创建所需的全功能编辑器。
二、编辑器列表
三、控件的演示代码:
四、编辑器的层次结构
- BaseEdit 的直属子类 (不包括 TextEdit 编辑器)。
该组中的每个编辑器都有自己的功能,并且没有与其他编辑器相同的功能。 - TextEdit 类及其直属子 MemoEdit 编辑器。
这些编辑器分别显示一个支持单行或多行文本编辑的文本框。 请参阅 文本编辑概述 主题,来获得关于这些编辑器及其子类的特定功能的细节。 - ButtonEdit 类及其直属子 HyperLinkEdit 编辑器。
除了继承的功能之外,这些编辑器还可以显示编辑器按钮。 请参阅 编辑器按钮概述 和 编辑器按钮快捷键 主题,来获得关于定制编辑器按钮的其他信息。 - BaseSpinEdit 类的直属子类 —— SpinEdit 和 TimeEdit 控件。
除了继承的功能之外,这些编辑器还允许最终用户使用微调按钮来修改取值。 请参阅 微调按钮 主题,来获得其他信息。 - PopupBaseEdit 类的子类。
除了继承的功能之外,这些编辑器还可以显示弹出窗口,并且允许控制其可用性、可视性和弹出窗口功能的其他外观。 请参阅 下拉编辑器概述 主题来学习更多内容。 - BlobBaseEdit 类的子类 —— ImageEdit 和 MemoExEdit 控件。
除了继承的功能之外,这些编辑器还提供了使用其弹出窗口编辑 BLOB 数据的功能。 请参阅 BLOB 编辑器 主题,来获得其他信息。 - LookUpEditBase 类的子类实现了查找功能。 该类有两个子类: LookUpEdit 和 GridLookUpEdit 编辑器。
GridLookUpEdit 控件使用一个内嵌 XtraGrid 控件实现了查找功能。 此控件由 XtraGrid 套件提供,并且不包括在 XtraEditors 库中。
要获得更多关于查找功能的信息,请参阅 LookUpEdit 主题。 - ComboBoxEdit 类及其子类 (ImageComboBoxEdit、MRUEdit 和 FontEdit)。
这些编辑器允许最终用户从下拉列表中选取某项取值。 请参阅 组合框编辑器 主题,来获知细节。 - TrackBarControl 类及其子类 (RangeTrackBarControl 和 ZoomTrackBarControl)
呈现滑动栏 —— 显示一个或两个滑动块的控件,允许最终用户选取某个取值或某个取值范围。 - ProgressBarBaseControl 的子类 —— ProgressBarControl 和 MarqueeProgressBarControl。
这些控件适用于指示漫长操作的进度。
BaseEdit
BaseCheckEdit
PictureEdit
ProgressBarBaseControl
RadioGroup
RatingControl
SparklineEdit
TextEdit
TokenEdit
TrackBarControl
TextEdit
MemoEdit
ButtonEdit
HyperLinkEdit
PopupBaseEdit
BaseSpinEdit
SpinEdit
TimeEdit
BlobBaseEdit
ImageEdit
MemoExEdit
CalcEdit
ColorEdit
DateEdit
PopupBaseAutoSearchEdit
ComboBoxEdit
LookUpEditBase
LookUpEdit
TreeListLookUpEdit
GridLookUpEditBase
GridLookUpEdit
SearchLookUpEdit
PopupContainerEdit
CheckedComboBoxEdit
ResourcesPopupCheckedListBoxControl
PopupGalleryEdit
五、与.net基本的控件比较
1. 命名空间(NameSpace)
.net基本控件的类都在System.Windows.Forms的命名空间下,DevExpress的控件类在DevExpress命名空间下
2. 可以代替.net的控件
DevExpress的大部分控件都已可以代替.net的基本控件。如:
- 按钮:
System.Windows.Forms.Button -> DevExpress.XtraEditors.SimpleButton - 文本框:
System.Windows.Forms.TextBox -> DevExpress.XtraEditors.TextEdit - 复选框
System.Windows.Forms.CheckBox -> DevExpress.XtraEditors.CheckEdit - 下拉框:
System.Windows.Forms.ComboBox -> DevExpress.XtraEditors.ComboBoxEdit - 日 期:
System.Windows.Forms.DateTimePicker -> DevExpress.XtraEditors.DateEdit / DevExpress.XtraEditors.TimeEdit
这里就不一一列举了,认真看看,相信一定找出很多可以替代的控件
六、几个比较重要、常用的属性
1:EditValue
DevExpress.XtraEditors.*Edit 的控件都不可少的一个EditValue属性。
如:DevExpress.XtraEditors.*Edit
通常,EditValue会跟Text的值是一样的。
只是EditValue的类型为Object,
而Text的属性为String,
也就是EditValue通常可以代替Text属性。
2. Enable 和 Visable
是否禁用和是否可见
3. Properties
设置控件一些特征
例如 是否只读:
textEdit.Properties.ReadOnly = true;
不允许获得焦点
textEdit.Properties.AllowFocused = false;
禁止空值输入
textEdit.Properties.AllowNullInput = false;
// 当这个属性应用在TimeEdit中,它的清除按钮,将会禁用(灰掉)
禁止编辑器输入
comboBoxEdit.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;// 只选模式,不能输入文本
4. Appearance 设置风格。
Dexpress把所有设置控件风格的特性都放到Appearance属性下。
例:
//前景色
simpleButton.Appearance.ForeColor = Color.Red;
//背景色
simpleButton.Appearance.BackColor = Color.Red;
Appearance.TextOptions 文本对齐操作
// 居中对齐
simpleButton.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
// 自动换行。当控件的宽度容不下文本的长度,会自动换行。
simpleButton.Appearance.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;
注意:
在某些控件中, Properties属性下才有Apperarance
DevExpress.XtraEditors.TextEdit textEdit = …;
textEdit.Properties.Appearance.ForeColor = Color.Red;
七. 几个常用的控件
1:LookUpEdit
用强大的LookUpEdit代替ComboBox
- ComboBox不支持数据绑定
- 由于DevExpress的ComboBox天生存在数据绑定缺陷,
所以有时我们要做数据绑定这种杀鸡小事时,不得不使用牛刀LooUpEdit。
如下代码,可用实现一个ComboBox:
// 禁止文本输入
this.lookUpEdit1.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
// 默认为null的显示
this.lookUpEdit1.Properties.NullText = "[请选择类别]";
// 加入一个显示列
this.lookUpEdit1.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Name"));
// 不显示页眉(包括列头)
this.lookUpEdit1.Properties.ShowHeader = false;
// 不显示页脚(包括关闭按钮)
this.lookUpEdit1.Properties.ShowFooter = false;
// 要显示的字段,Text获得
this.lookUpEdit1.Properties.DisplayMember = "Name";
// 实际值的字段,EditValue获得
this.lookUpEdit1.Properties.ValueMember = "Value";
// 数据绑定
ICollection list = Global.ClassCategoryList;
// 绑定数据
this.lookUpEdit1.Properties.DataSource = list;
// 设置行数(根据这个自动设置高度)
this.lookUpEdit1.Properties.DropDownRows = list.Count;
2. GridControl
GridControl可以代替.net的System.Windows.Forms.DataGrid控件。
GirdControl只是一个容器控件,必须要求GridView视图作为它的子控件。
GridControl可以包含多个视图,可以实现视图的切换。
每个GridView视图必须包含列(Column)
GridControl支持层级视图
GridControl 经常设置的属性
使用导航器
this.gridControl1.UseEmbeddedNavigator = true; this.gridControl1.EmbeddedNavigator.Buttons.Append.Visible = false;
this.gridControl1.EmbeddedNavigator.Buttons.CancelEdit.Visible = false;
this.gridControl1.EmbeddedNavigator.Buttons.Edit.Visible = false;
this.gridControl1.EmbeddedNavigator.Buttons.EndEdit.Visible = false;
this.gridControl1.EmbeddedNavigator.Buttons.Remove.Visible = false; this.gridControl1.EmbeddedNavigator.Buttons.First.Visible = true;
this.gridControl1.EmbeddedNavigator.Buttons.Last.Visible = true;
this.gridControl1.EmbeddedNavigator.Buttons.Next.Visible = true;
this.gridControl1.EmbeddedNavigator.Buttons.NextPage.Visible = true;
this.gridControl1.EmbeddedNavigator.Buttons.Prev.Visible = true;
this.gridControl1.EmbeddedNavigator.Buttons.PrevPage.Visible = true;
GridView 经常设置的属性
// 禁止编辑
this.gridView1.OptionsBehavior.Editable = false; // 不允许使用过滤
this.gridView1.OptionsCustomization.AllowFilter = false; // 不允许使用排序
this.gridView1.OptionsCustomization.AllowSort = false; // 不显示组面板
this.gridView1.OptionsView.ShowGroupPanel = false; // 如果宽度溢出,自动出现滚动条 this.gridView1.OptionsView.ColumnAutoWidth =true; // 禁止单元格获得焦点
this.gridView1.OptionsSelection.EnableAppearanceFocusedCell = false; // 选择的行背景透明
this.gridView1.Appearance.SelectedRow.BackColor = Color.Transparent;
事件
//订阅行焦点改变事件
this.gridView1.FocusedRowChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventHandler(this.gridView1_FocusedRowChanged); //验证编辑器(单元格)值输入
this.gridView1.ValidatingEditor += new DevExpress.XtraEditors.Controls.BaseContainerValidateEditorEventHandler(this.gridView1_ValidatingEditor); private void gridView1_ValidatingEditor(object sender, DevExpress.XtraEditors.Controls.BaseContainerValidateEditorEventArgs e)
{
if (gridView1.FocusedColumn == col产品名称)
{
if (string.IsNullOrEmpty(e.Value as string)) {
e.ErrorText = "产品名称不能为空";
e.Valid = false;
}
}
}
//订阅设置行风格事件
this.gridView1.RowStyle += new DevExpress.XtraGrid.Views.Grid.RowStyleEventHandler(this.gridView1_RowStyle); private void gridView1_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e)
{
object value = gridView1.GetRowCellValue(e.RowHandle, "中止");
if (value!=null&&(bool)value) {
e.Appearance.ForeColor = Color.Red;
}
} this.gridView1.CustomColumnDisplayText += new DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventHandler(this.gridView1_CustomColumnDisplayText); private DataTable _CategoryList; public DataTable CategoryList {
get {
if (_CategoryList == null) {
_CategoryList=GetData("select * from 产品类别");
DataColumn pk = _CategoryList.Columns["类别ID"];
_CategoryList.PrimaryKey = new DataColumn[] {pk};
}
return _CategoryList;
}
} private void gridView1_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
{
if (e.Column.Name == "col类别ID") {
e.DisplayText = CategoryList.Rows.Find(e.Value)["类别名称"] as string;
}
} // 行单元格对齐
this.gridView1.RowCellDefaultAlignment += new DevExpress.XtraGrid.Views.Base.RowCellAlignmentEventHandler(this.gridView1_RowCellDefaultAlignment); private void gridView1_RowCellDefaultAlignment(object sender, DevExpress.XtraGrid.Views.Base.RowCellAlignmentEventArgs e)
{
e.HorzAlignment = DevExpress.Utils.HorzAlignment.Near;
}
3. 界面操作
3.1 根据条件操作行或列风格
3.2 添加RepositoryItem(内嵌元素In-place EditorRepository)
3.3 列汇总
首先,设置this.gridView1.OptionsView.ShowFooter = true;
this.col库存量.SummaryItem.DisplayFormat = “总量:{0}”;
// 六种:Sum,Average,Count,Max,Min,Custom
col单位数量.SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum;
XtraEditors一、总体介绍的更多相关文章
- ABP(现代ASP.NET样板开发框架)系列之1、ABP总体介绍
点这里进入ABP系列文章总目录 基于DDD的现代ASP.NET开发框架--ABP系列之1.ABP总体介绍 ABP是“ASP.NET Boilerplate Project (ASP.NET样板项目)” ...
- 基于MVC4+EasyUI的Web开发框架形成之旅--总体介绍
最近花了很多时间在重构和进一步提炼Winform开发框架的工作上,加上时不时有一些项目的开发工作,我博客里面介绍Web开发框架的文章比较少,其实以前在单位工作,80%的时间是做Web开发的,很早就形成 ...
- TMS320C54x系列DSP的CPU与外设——第2章 TMS320C54x DSP体系结构总体介绍
第2章 TMS320C54x DSP体系结构总体介绍 本章介绍TMS320C54x DSP体系结构的概况,包括中央处理单元(CPU).存在器和片内外设. C54x DSP采用了高级的改进哈佛结构,用8 ...
- 飞达资讯App总体介绍及关系架构图
飞达资讯App总体介绍: 下图为飞达资讯App的关系架构图: 该App关系架构图所需的图片云盘链接地址:http://pan.baidu.com/s/1gfHIe4b 提取密码:x1nr 该App的云 ...
- 基于WebForm+EasyUI的业务管理系统形成之旅 -- 总体介绍
一.系统总体介绍 企业业务管理系统是针对经营企业管理而开发的专业管理软件, 是以“精细管理.过程监控”为设计理念,全面满足企业的信息化管理需求,充分发挥专业.平台.灵活等优点. 集进销存.财务.CRM ...
- EQueue - 一个C#写的开源分布式消息队列的总体介绍(转)
源: EQueue - 一个C#写的开源分布式消息队列的总体介绍 EQueue - 一个纯C#写的分布式消息队列介绍2 EQueue - 详细谈一下消息持久化以及消息堆积的设计
- AngularJs学习笔记1——总体介绍
这周末在家呆了两天,正好中午闲暇时间继续分享Angularjs相关,今天主要分享Angularjs总体介绍及数据绑定部分内容,下面直接进入主题. 1.基本概念: AngularJS是为了克服HTML在 ...
- [转帖]Kubernetes及容器编排的总体介绍【译】
Kubernetes及容器编排的总体介绍[译] 翻译自The New Stack<Kubernetes 生态环境>作者:JANAKIRAM MSV和 KRISHNAN SUBRAMANIA ...
- 基于DDD的现代ASP.NET开发框架--ABP系列之1、ABP总体介绍
点这里进入ABP系列文章总目录 基于DDD的现代ASP.NET开发框架--ABP系列之1.ABP总体介绍 ABP是“ASP.NET Boilerplate Project (ASP.NET样板项目)” ...
- 1.bash总体介绍
1.总体介绍1.1 什么是Bash?Bash(Borune-Again SHell)是一个用于Linux操作系统的shell,即命令解释器Bash与sh兼容,并从ksh和csh引进了一些有用的功能,在 ...
随机推荐
- Ionic3 UI组件之 ImagePicker
ImagePicker插件实现设备上的多个图像选择的功能. 组件特性: 统一选择界面,避免不同设备选择界面不一样的问题: 支持多选,并且可以设置最多选择的张数: 选择数量超出设置时会提示: Camer ...
- 撰写html标签的快捷方式1
一: <ul> <li><a href=""></a></li></ul> 如果要写上面的标签,直接写 ul ...
- java设计模式-----15、适配器模式
概念: Adapter模式也叫适配器模式,是构造型模式之一,通过Adapter模式可以改变已有类(或外部类)的接口形式. 举个例子:我们使用电脑,家里的电源是220V的,而我们的电脑是18V的,这时如 ...
- MangoDB的C#驱动库(.net framewokr 4.0)
编写运维工具,需要联接MangoDB 基于我陈旧的技术栈,就用c#开发了 驱动库下载地址记录到至此,需要的可以下载 注意,此驱动是老版本的,只支持.net framewokr 4.0 看了半天,觉得够 ...
- LeetCode CombinationSum
class Solution { public: vector<vector<int> > combinationSum(vector<int> &cand ...
- 当div元素内的内容超出其宽度时,自动隐藏超出的内容
word-break:keep-all;/* 不换行 */ white-space:nowrap;/* 不换行 */ overflow:hidden;/* 内容超出宽度时隐藏超出部分的内容 */ te ...
- WPF 手机验证码 发送按钮倒计时 代码
private async void SendButton_Click(object sender, RoutedEventArgs e) { var button = sender as Butto ...
- Eclipse环境开发Teamcenter RAC
外包发过来的RAC程序老是报错,导致测试走不下去.Bug修复响应太慢,用jad看了下代码也不是很复杂,决定自己调试.在Eclipse 环境下开发Teamcenter RAC一般是用Eclipse,在做 ...
- Flutter 案例学习之:GridView
GitHub:https://github.com/happy-python/flutter_demos/tree/master/gridview_demo 在 ListView 中,如果将屏幕的方向 ...
- Linux+db2+was部署问题总结
Linux+db2+was部署问题总结 前段日子在住建部进行了Linux环境下,db2+rbp+was的部署,由于是集群,切涉及到了很多was的东西,搞了很长时间,在此做一个问题总结,供后续查询 ...