DevExpress入门教程.ppt

上传人:壹****1 文档编号:568508959 上传时间:2024-07-25 格式:PPT 页数:21 大小:1.43MB
返回 下载 相关 举报
DevExpress入门教程.ppt_第1页
第1页 / 共21页
DevExpress入门教程.ppt_第2页
第2页 / 共21页
DevExpress入门教程.ppt_第3页
第3页 / 共21页
DevExpress入门教程.ppt_第4页
第4页 / 共21页
DevExpress入门教程.ppt_第5页
第5页 / 共21页
点击查看更多>>
资源描述

《DevExpress入门教程.ppt》由会员分享,可在线阅读,更多相关《DevExpress入门教程.ppt(21页珍藏版)》请在金锄头文库上搜索。

1、DeVExpress控件入门简介简介: XtraEditors Library是专门为可视化的Studio.NET设计的最优化的一套100的C#控件 XtraEdiotors Library是一款具有革命性的超过20种数据编辑控制的控件它是国内第一个适合于.NET框架类型的控件。广州易麦科技 http:/准备工作1.DevExpress控件的安装2.Demo查看3.帮助文档使用广州易麦科技 http:/一:与.net基本的控件比较1:命名空间(NameSpace).net基本控件的类都在System.Windows.Forms的命名控件下DevExpress的控件类在DevExpress命名空

2、间下广州易麦科技 http:/2:可以代替.net的控件DevExpress的大部分控件都已可以代码.net的基本控件。如:文本框:System.Windows.Forms.TextBox - DevExpress.XtraEditors.TextEdit按钮:System.Windows.Forms.Button - DevExpress.XtraEditors.SimpleButton下拉框:System.Windows.Forms.ComboBox - DevExpress.XtraEditors.ComboBoxEdit广州易麦科技 http:/日期:System.Windows.Fo

3、rms.DateTimePicker - DevExpress.XtraEditors.DateEdit/DevExpress.XtraEditors.TimeEdit复选框System.Windows.Forms.CheckBox - DevExpress.XtraEditors.CheckEdit这里就不一一列举了,认真看看,相信一定找出很多可以替代的控件广州易麦科技 http:/二:几个比较重要、常用的属性1:EditValue DevExpress.XtraEditors.*Edit的控件都不可少的一个EditValue属性。如:DevExpress.XtraEditors.*Edit

4、 通常,EditValue会跟Text的值是一样的。只是EditValue的类型为Object,Text的属性为String,也就是EditValue通常可以代替Text属性。2:Enable和Visable 是否禁用和是否可见广州易麦科技 http:/3:Properties设置控件一些特征DevExpress.XtraEditors.TextEdit txt=.;例:是否只读txt.Properties.ReadOnly=true;不允许获得焦点txt.Properties.AllowFocused = false;不允许空值输入txt.Properties.AllowNullInput=

5、true;/当这个属性应用在TimeEdit中,它的清除按钮,将会禁用(灰掉)广州易麦科技 http:/禁止编辑器输入如:ComboBoxEdit c=.; c.Properties.TextEditStyle=DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;/只选模式,不能输入文本广州易麦科技 http:/4:Appearance设置风格。Dexpress把所有设置控件风格的特性都放到Appearance属性下。例:DevExpress.XtraEditors.SimpleButton btn=.;btn.Ap

6、pearance.ForeColor = Color.Red;/前景色btn.Appearance.BackColor = Color.Red;/背景色广州易麦科技 http:/ Appearance.TextOptions文本对齐操作例:btn.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;/居中对齐btn.Appearance.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;/自动换行。当控件的宽度容不下文本的长度,会自动换行。注

7、意,在某些控件中Apperarance是在Properties属性下的如:DevExpress.XtraEditors.TextEdit txt=.;txt.Properties.Appearance.ForeColor = Color.Red;广州易麦科技 http:/三:几个常用的控件1:用强大的LookUpEdit代替ComboBox 1.1 ComboBox不支持数据绑定2.1 由于DevExpress的ComboBox天生的数据绑定缺陷,所以有时我们要做数据绑定,不得不使用下“功能过剩”的LooUpEdit。如下代码,可用实现一个ComboBox:广州易麦科技 http:/ /禁止文

8、本输入禁止文本输入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)

9、; this.lookUpEdit1.Properties.ShowHeader=false;/不显示页眉(包括不显示页眉(包括列头)列头)this.lookUpEdit1.Properties.ShowFooter = false;/不显示页脚不显示页脚(包括关闭按钮)(包括关闭按钮)this.lookUpEdit1.Properties.DisplayMember = Name;/要显要显示的字段示的字段,Text获得获得this.lookUpEdit1.Properties.ValueMember = Value;/实际值实际值的字段的字段,EditValue获得获得/数据绑定数据绑定I

10、Collection list = Global.ClassCategoryList; this.lookUpEdit1.Properties.DataSource = list;/绑定数据绑定数据this.lookUpEdit1.Properties.DropDownRows =list.Count;/设设置行数置行数(根据这个自动设置高度根据这个自动设置高度)广州易麦科技 http:/ 2:GridControlGridControl可以代替.net的System.Windows.Forms.DataGrid控件。GirdControl只是一个容器控件,必须要求GridView视图作为它的

11、子控件。GridControl可以包含多个视图,可以实现视图的切换。每个视图必须包含列(Column)GridControl支持层级视图广州易麦科技 http:/GridControl常设置属性常设置属性使用导航器使用导航器this.gridControl1.UseEmbeddedNavigator = true; this.gridControl1.EmbeddedNavigator.Buttons.Append.Visible = false; this.gridControl1.EmbeddedNavigator.Buttons.CancelEdit.Visible = false; t

12、his.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.EmbeddedNaviga

13、tor.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;

14、广州易麦科技 http:/GridView常设置属性常设置属性this.gridView1.OptionsBehavior.Editable = false;/禁止编辑禁止编辑this.gridView1.OptionsCustomization.AllowFilter = false;/不允许使用过滤不允许使用过滤this.gridView1.OptionsCustomization.AllowSort = false;/不允许使用排序不允许使用排序this.gridView1.OptionsView.ShowGroupPanel = false;/不显示组面板不显示组面板 this.gri

15、dView1.OptionsView.ColumnAutoWidth =true;/如如果宽度溢出,自动出现滚动条果宽度溢出,自动出现滚动条 this.gridView1.OptionsSelection.EnableAppearanceFocusedCell = false;/禁止单元格获得焦点禁止单元格获得焦点this.gridView1.Appearance.SelectedRow.BackColor = Color.Transparent;/选择的行背景透明选择的行背景透明广州易麦科技 http:/事件事件/订阅行焦点改变事件订阅行焦点改变事件this.gridView1.Focuse

16、dRowChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventHandler(this.gridView1_FocusedRowChanged);/验证编辑器(单元格)值输入验证编辑器(单元格)值输入this.gridView1.ValidatingEditor += new DevExpress.XtraEditors.Controls.BaseContainerValidateEditorEventHandler(this.gridView1_ValidatingEditor);private void gr

17、idView1_ValidatingEditor(object sender, DevExpress.XtraEditors.Controls.BaseContainerValidateEditorEventArgs e) if (gridView1.FocusedColumn = col产品名称产品名称) if (string.IsNullOrEmpty(e.Value as string) e.ErrorText = 产品名称不能为空产品名称不能为空; e.Valid = false; 广州易麦科技 http:/ += new DevExpress.XtraGrid.Views.Grid.

18、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; 广州易麦科技 http:/this.gridView1.C

19、ustomColumnDisplayText += 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 = _Categor

20、yList.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)类别名称类

21、别名称 as string; 广州易麦科技 http:/ += 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.HorzAli

22、gnment.Near; .广州易麦科技 http:/3:界面操作3.1根据条件操作行或列风格3.2添加RepositoryItem(内嵌元素)3.3列汇总首先,设置this.gridView1.OptionsView.ShowFooter = true;this.col库存量.SummaryItem.DisplayFormat = 总量:0;/六种:Sum,Average,Count,Max,Min,Customcol单位数量.SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum;广州易麦科技 http:/四:数据检查、验证1.演示Mask2.DXValidationProvider的组件使用广州易麦科技 http:/

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 高等教育 > 研究生课件

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号