devexpress treelist的用法
devexpress 控件用法

devexpress 控件用法DevExpress是一个强大的控件库,专为.NET开发人员设计。
它提供了一系列易于使用且功能丰富的控件,可以帮助开发人员更快速地构建各种类型的应用程序,从基本的桌面应用程序到复杂的企业级解决方案。
在本文中,我们将以中括号为主题,一步一步地介绍DevExpress控件的用法。
第一步:准备工作在开始使用DevExpress控件之前,需要进行一些准备工作。
首先,您需要在开发计算机上安装DevExpress控件库。
您可以从DevExpress官方网站下载并安装控件库的最新版本。
安装完成后,您需要在.NET项目中添加对DevExpress控件库的引用。
第二步:控件的基本用法DevExpress控件库提供了多个控件类别,包括界面控件、数据控件、布局控件等。
每个类别都包含多个具体的控件类型。
在使用控件之前,您需要根据项目需求选择合适的控件类型。
界面控件是DevExpress控件库中最常用的控件之一。
它们用于构建应用程序的用户界面。
常用的界面控件包括按钮、文本框、标签、下拉框等。
要使用界面控件,您需要在设计窗体或用户控件时将其拖放到设计器中,并设置其属性和事件处理程序。
数据控件用于显示和操作数据。
它们可以从数据库、文件或其他数据源中检索数据,并将其显示在界面上。
常用的数据控件包括表格控件、列表控件和树控件等。
使用数据控件时,您可以通过绑定数据源和设置数据过滤条件来配置它们。
布局控件用于组织界面上的其他控件。
它们提供了一种简便的方法来排列和调整控件的位置和大小。
常用的布局控件包括面板、分组框和标签页等。
使用布局控件时,您可以将其他控件放置在布局控件的容器中,并调整它们的布局样式。
第三步:控件的高级用法在掌握了DevExpress控件的基本用法后,您可以开始使用它们的高级功能。
DevExpress控件提供了许多高级功能,可以提高应用程序的性能和用户体验。
一个常见的高级用法是自定义控件的外观和样式。
DevExpress控件使用说明

EF.DLL 的介绍 1.EF.dll 中的 Form
结构如下:
如上图所示--常用的是 EFForm 1) 继承 :父类有的,子类都会继承 ( 如 EFFormMain 中的东西,到了 EFForm 中,原来使用 EFFormMain 的对象调用的,现在使用 EFForm 的对象都可以调用, EFFormMasterDetail 类 似) 2)简单点如下: 可认为 EFFormMain 是基类,空的,看上去什么都没有, EFForm 为它添加了下方的 F1--F12 按钮栏,可以通过授权控制按钮是否显示. EFFormMasterDetail 是在 EFForm 上添加了一个 Panel 和一个 TabControl 控件 EFFormListDetail 是添加了一个 LayoutControl 并定义了上中下(查询条件,列表,详细)的格 局 EFFormMasterDetail2 是继承自 EFFormMasterDetail 的一个未完成的画面 .定义了工具栏上按 钮的操作对应的默认实现 EFFormListDetail2 是继承自 EFFormListDetail 的一个未完成的画面 . 定义了工具栏上按钮 的操作对应的默认实现 一般情况下窗体都直接继承自 EFForm
属性:
2.4 EFDevSpinEdit 数值输入控件
数值输入框.如下.由一个 EFDevTextEdit 和一个上下翻动的按钮组成,用户可点击按钮调整 值.
简单说明: 1.只能输入数值型(整数或者小数,包含负数) 2.可控制可输入的最大值和最小值(MaxValue,MinValue) 3.控制最大长度(MaxLength) 4.控制是否可输入小数(IsFloatValue) 5.可控制点击按钮式,增加或减少的值大小(Increment 属性) 主要属性如下图所示:
DevExpress控件属性说明

DevExpress控件属性说明TcxGridAlign设置控件的排列方式。
alBottom:相对于父容器为底端对齐排列。
alClient:相对于父容器为剩余部分完全覆盖排列。
alCustom:相对于父容器为自定义对齐排列。
alLeft:相对于父容器为左端对齐排列。
alNone:默认对齐排列。
alRight:相对于父容器为右端对齐排列。
alTop:相对于父容器为顶端对齐排列。
AlignWithMargins设置控件与其父容器之间的间隙。
Anchors设置控件的对齐方式。
akLeft当其父容器大小改变时,控件左端相对于父容器左端的位置不变。
akTop当其父容器大小改变时,控件顶端相对于父容器顶端的位置不变。
akRight当其父容器大小改变时,控件右端相对于父容器右端的位置不变。
akBottom当其父容器大小改变时,控件底端相对于父容器底的位置不变。
BevelEdges设置控件的是否显示斜面。
beLeft控件左端。
beTop控件顶端。
beRight控件右端。
beBottom控件底端。
BevelInner设置斜面内部的样式。
bvLowered:下凹式。
bvNone:无样式。
bvRaised:凸起式。
bvSpace:间隔式。
BevelKind设置斜面样式。
bkFlat:平坦式。
bkNone:无样式。
bkSoft:柔和式。
bkTile:凸起式。
BevelOuter设置斜面外部样式。
bvLowered:下凹式。
bvNone:无样式。
bvRaised:凸起式。
bvSpace:间隔式。
BevelWidth设置斜面宽度。
BorderStyle设置边框样式。
cxcbsDefault:默认样式。
cxcbsNone:无样式。
BorderWidth设置边框宽度。
Constraints设置控件的尺寸的限制。
MaxHeight最大高度。
MaxWidth最大宽度MinHeight最小高度。
MinWidth最小宽度。
Cursor设置指针样式。
DevExpress控件运用

5表示当前是第五条记录,12表示总记录条数 OptionsBehavior Editable/ReadOnly 不可编辑状态
12
5. GridControl
LayoutView.OptionsCarouselMode 属性,包括了椭圆的螺旋角和转动角:
13
5.GridControl
CardView
11
5. GridControl
LayoutView
多种卡片布局,可以通过 LayoutView.OptionsView.ViewMode 属性设置 1.单张卡片 2.单行 3.单列 4.多行 5.多列 6.Carousel LayoutView.OptionsMultiRecordMode.MaxCardRows LayoutView.OptionsMultiRecordMode.MaxCardColumns 卡片的对齐方式LayoutView.OptionsView.ContentAlignment 属性卡片内容对齐 LayoutViewOptionsView.CardsAlignment 卡片对齐 Carousel 布局 参数可以通过 LayoutView.OptionsCarouselMode 属性设置 CardCaptionFormat 指定卡片标题的模式。 在默认情况下,此属性的值是“ Record N {0}”。 意思是卡片标题显示后接记录号的“Record N ”字符串。 也可以 强制使卡片视图显示卡片内的字段值。 例如,把 CardCaptionFormat 属性设置 为 “{3} ” 则显示第二列的值 默认为下图
DefaultLookAndFeel 皮肤控件
5
3.BarManager 、NavBarControl
DevExpress使用技巧

DevExpress使用技巧一、DevExpress控件使用使用技巧小结零零散散的先总结一下吧1.TextEditor(barEditItem)取文本string editValue = barEditItem1.EditValue.ToString(); //错误,返回nullstring editValue =((DevExpress.XtraEditors.TextEdit)barEditItem).EditValue.ToString(); //正确,返回文本框内容boBoxEdit(barEditItem)添加Itemstring item = "comboboxItem1";((DevExpress.XtraEditors.Repository.RepositoryItemComboBox)this.barE ditItem.Edit).Items.Add(item);boBoxEdit(barEditItem)取文本string itemValue = this.barEditItem.EditValue.ToString();4.Ribbon控件//添加PageDevExpress.XtraBars.Ribbon.RibbonPage ribbonPage = new RibbonPage();ribbonControl.Pages.Add(ribbonPage); //添加GroupDevExpress.XtraBars.Ribbon.RibbonPageGroup ribbonPageGroup = new RibbonPageGroup();ribbonPage.Groups.Add(ribbonPageGroup); //添加ButtonDevExpress.XtraBars.BarButtonItem barButtonItem = newBarButtonItem();ribbonPageGroup.ItemLinks.Add(barButtonItem); //添加barSubItemDevExpress.XtraBars.BarSubItem barSubItem = new BarSubItem();ribbonPageGroup.ItemLinks.Add(barSubItem); //barSubItem下添加Button barSubItem.AddItem(barButtonItem);4.奇怪的删除Page问题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); //运行正常}5.RIBBON问题汇集//禁止F10键TipseF10KeyForMenu = false; //DX按钮ApplicationIcon属性改变图标右键 Add ApplicationMenu 添加evExpress.XtraBars.Ribbon.ApplicationMenu5.HitInfo //在Tab页上点击右键的事件响应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.皮肤//添加皮肤程序集后注册皮肤erSkins.OfficeSkins.Register();erSkins.BonusSkins.Register();//设置皮肤erLookAndFeel.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 = newFont(this.Font.FontFamily, currentFontSize);9.设置系统字体DevExpress.Utils.AppearanceObject.DefaultFont = newFont(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部分使用技巧(原创) 作者 : 轻舞肥羊标题 : DevExpress部分使用技巧(原创)关键字: DevExpress,cxGrid分类 : 开发技巧密级 : 公开(评分:???? , 回复: 7, 阅读: 8588) »»本文由轻舞肥羊发表于大富翁论坛转载请标明出处,谢谢声明:以下代码请看懂再使用,本人水平有限,发现bug希望提出,让我们共同改进2004-1-10 17:06:00查看评语»»»1.扩展cxLookupComboBox,使其支持多列查询的cxLookupComboBoxEx日期:2004-1-10 17:08:06//================================================================== ============// Unit Name: cxLookupComboBoxEx // Author : ysai// Date : 2003// Purpose : 扩展cxLookupComboBox,cxDBLookupComboBox,使其支持多列过滤 // History :// 2003-05-28大数据量改进// 2003-07-07可操作性改进// 2003-08-20效率改进// 2003-08-29加入过滤延时// 注意:// 限制1,不能再使用Properties.OnChange事件// 限制2,不能再使用Properties.ListSource.DataSet.OnFilterRecord事件// 限制3,不能再使用Properties.ListSource.DataSet.Filtered属性 // 其它,最好在设计期设好一切属性,运行期再设置属性可能引发求知错误//===================================================================== =========unit cxLookupComboBoxEx;interfaceusesSysUtils, Classes, Controls, Windows, Messages,DB,StrUtils,cxControls, cxContainer, cxEdit, cxTextEdit,cxMaskEdit, cxDropDownEdit, cxLookupEdit, cxDBLookupEdit,cxDBLookupComboBox;typeTcxLookupComboBoxEx = class(TcxLookupComboBox)private//保存要过滤的字段列表FFieldList : TList;FFindText : String;//过滤事件procedure _OnFilterRecord(DataSet: TDataSet; var Accept: Boolean); //编辑框文字改变事件procedure _OnChange(Sender : TObject);procedure GetFieldList;//延时过滤消息procedure WMTimer (var Message: TMessage); message WM_TIMER; protected//下拉表格收回时procedure CloseUp(AAccept: Boolean); override;//过滤过程procedure _FilterListSource;//初始化下拉表格事件procedure DoInitPopup; override;publicconstructor Create(AOwner : TComponent); override;destructor Destroy; override;//更新要过滤的字段列表procedure UpdateFilterFields;publishedend;TcxDBLookupComboBoxEx = class(TcxDBLookupComboBox)private//保存要过滤的字段列表FFieldList : TList;FFindText : String;//过滤事件procedure _OnFilterRecord(DataSet: TDataSet; var Accept: Boolean); //编辑框文字改变事件procedure _OnChange(Sender : TObject);//取得要过滤的字段列表procedure GetFieldList;//延时过滤消息procedure WMTimer (var Message: TMessage); message WM_TIMER; protected//下拉表格收回时procedure CloseUp(AAccept: Boolean); override;//过滤过程procedure _FilterListSource;//初始化下拉表格事件procedure DoInitPopup; override;publicconstructor Create(AOwner : TComponent); override;destructor Destroy; override;//更新要过滤的字段列表procedure UpdateFilterFields;publishedend;procedure Register;implementationconstUM_TIMER_FILTER = WM_USER + $101; //自定义延时消息IDFILTERTIMER = 500; //延时时间DROPDOWN_ROWS = 12;procedure Register;beginRegisterComponents('Dev Express', [TcxLookupComboBoxEx,TcxDBLookupComboBoxEx]);end;{ TcxLookupComboBoxEx }procedure TcxLookupComboBoxEx.CloseUp(AAccept: Boolean);begininherited;//收起下拉后取消过滤if Assigned(Properties.ListSource) thenif Assigned(Properties.ListSource.DataSet) thenProperties.ListSource.DataSet.Filtered := False; end;constructor TcxLookupComboBoxEx.Create(AOwner: TComponent); begin inherited;//默认值Properties.AutoSelect := False;Properties.DropDownAutoSize := True;Properties.DropDownListStyle := lsEditList;Properties.DropDownRows := DROPDOWN_ROWS;Properties.DropDownSizeable := True;Properties.IncrementalFiltering := False;Properties.Revertable := True;Properties.OnChange := _OnChange;eLeftAlignmentOnEditing := False; end;destructor TcxLookupComboBoxEx.Destroy;begin//释放过滤字段列表if Assigned(FFieldList) then FFieldList.Free;inherited;end;procedure TcxLookupComboBoxEx.DoInitPopup; begin//取得过滤字段if Assigned(Properties.ListSource) thenif Assigned(Properties.ListSource.DataSet) thenbeginGetFieldList;Properties.ListSource.DataSet.Filtered := False;end;inherited DoInitPopup;end;procedure TcxLookupComboBoxEx._FilterListSource; //过滤字段beginif Assigned(Properties.ListSource)and Assigned(Properties.ListSource.DataSet) thentryProperties.ListSource.DataSet.DisableControls;Properties.ListSource.DataSet.Filtered := False;Properties.ListSource.DataSet.OnFilterRecord := _OnFilterRecord; if Text <> '' thenbeginFFindText := Text;if SelLength > 0 thenFFindText := LeftStr(Text,SelStart);Properties.ListSource.DataSet.Filtered := FFindText <> '';end;Changed;finallyProperties.ListSource.DataSet.EnableControls;end;end;procedure TcxLookupComboBoxEx.GetFieldList; //取得过滤字段列表vari : Integer;sFieldName : String;fdTemp : TField;beginif not Assigned(FFieldList) thenbeginFFieldList := TList.Create;for i:=0 to Properties.ListColumns.Count -1 dobeginsFieldName := Properties.ListColumns.Items[i].FieldName;if sFieldName = '' then Continue;fdTemp := Properties.ListSource.DataSet.FindField(sFieldName);if Assigned(fdTemp) thenFFieldList.Add(Pointer(fdTemp));end;end;end;procedure TcxLookupComboBoxEx._OnChange(Sender: TObject); //设置延时beginif Focused and DroppedDown thenbeginKillTimer(Handle,UM_TIMER_FILTER);SetTimer(Handle,UM_TIMER_FILTER,FILTERTIMER,nil);end;end;procedure TcxLookupComboBoxEx._OnFilterRecord(DataSet: TDataSet; var Accept: Boolean);//过滤事件vars : String;i : Integer;begins := LowerCase(FFindText);if (s <> '') and (Properties.ListColumns.Count > 0) thenbeginAccept := False;for i := 0 to FFieldList.Count -1 dobeginAccept := Pos(s,LowerCase(TField(FFieldList[i]).AsString))>0;if Accept then Exit;end;endelseAccept := True;end;procedure TcxLookupComboBoxEx.WMTimer(var Message: TMessage);//延时更新消息beginKillTimer(Handle,UM_TIMER_FILTER);if Focused and DroppedDown then _FilterListSource; end;procedure TcxLookupComboBoxEx.UpdateFilterFields; //更新要过滤的字段列表beginif Assigned(FFieldList) thenbeginFFieldList.Free;FFieldList := nil;end;GetFieldList;end;{ TcxDBLookupComboBoxEx }procedure TcxDBLookupComboBoxEx.CloseUp(AAccept: Boolean); begin inherited;//收起下拉后取消过滤if Assigned(Properties.ListSource) thenif Assigned(Properties.ListSource.DataSet) thenProperties.ListSource.DataSet.Filtered := False; end;constructor TcxDBLookupComboBoxEx.Create(AOwner: TComponent); begininherited;//默认值Properties.AutoSelect := False;Properties.DropDownListStyle := lsEditList; Properties.DropDownRows := DROPDOWN_ROWS; Properties.DropDownSizeable := True;Properties.IncrementalFiltering := False; Properties.Revertable := True;Properties.OnChange := _OnChange;eLeftAlignmentOnEditing := False; end; destructor TcxDBLookupComboBoxEx.Destroy;begin//释放过滤字段列表if Assigned(FFieldList) then FFieldList.Free; inherited;end;procedure TcxDBLookupComboBoxEx.DoInitPopup; begin //取得过滤字段if Assigned(Properties.ListSource) thenif Assigned(Properties.ListSource.DataSet) then beginGetFieldList;Properties.ListSource.DataSet.Filtered := False; end;inherited DoInitPopup;end;procedure TcxDBLookupComboBoxEx._FilterListSource; //过滤字段beginif Assigned(Properties.ListSource)and Assigned(Properties.ListSource.DataSet) thentryProperties.ListSource.DataSet.DisableControls;Properties.ListSource.DataSet.Filtered := False;Properties.ListSource.DataSet.OnFilterRecord := _OnFilterRecord; if Text <> '' thenbeginFFindText := Text;if SelLength > 0 thenFFindText := LeftStr(Text,SelStart);Properties.ListSource.DataSet.Filtered := FFindText <> '';end;Changed;finallyProperties.ListSource.DataSet.EnableControls;end;end;procedure TcxDBLookupComboBoxEx.GetFieldList; //取得过滤字段列表vari : Integer;sFieldName : String;fdTemp : TField;beginif not Assigned(FFieldList) thenbeginFFieldList := TList.Create;for i:=0 to Properties.ListColumns.Count -1 dobeginsFieldName := Properties.ListColumns.Items[i].FieldName;if sFieldName = '' then Continue;fdTemp := Properties.ListSource.DataSet.FindField(sFieldName);if Assigned(fdTemp) thenFFieldList.Add(Pointer(fdTemp));end;end;end;procedure TcxDBLookupComboBoxEx._OnChange(Sender: TObject); //设置延时beginif Focused and DroppedDown thenbeginKillTimer(Handle,UM_TIMER_FILTER);SetTimer(Handle,UM_TIMER_FILTER,FILTERTIMER,nil);end;end;procedure TcxDBLookupComboBoxEx._OnFilterRecord(DataSet: TDataSet; var Accept: Boolean);//过滤事件vars : String;i : Integer;begins := LowerCase(FFindText);if (s <> '') and (Properties.ListColumns.Count > 0) thenbeginAccept := False;for i := 0 to FFieldList.Count -1 dobeginAccept := Pos(s,LowerCase(TField(FFieldList[i]).AsString))>0;if Accept then Exit;end;endelseAccept := True;end;procedure TcxDBLookupComboBoxEx.WMTimer(var Message: TMessage);//延时更新消息beginKillTimer(Handle,UM_TIMER_FILTER);if Focused and DroppedDown then _FilterListSource; end;procedure TcxDBLookupComboBoxEx.UpdateFilterFields; //更新要过滤的字段列表beginif Assigned(FFieldList) thenbeginFFieldList.Free;FFieldList := nil;end;GetFieldList;end;end.2.动态生成TcxGridDBTableView的列及页脚的合计栏日期: 2004-1-10 17:14:06vari : Integer;cl : TcxGridDBColumn;beginScreen.Cursor := crHourGlass;cxtvMaster.BeginUpdate;trycxtvMaster.ClearItems;cxtvMaster.DataController.Summary.FooterSummaryItems.Clear;for i := 0 to cxtvMaster.DataController.DataSet.FieldCount - 1 do begincl := cxtvMaster.CreateColumn;cl.DataBinding.FieldName :=cxtvMaster.DataController.DataSet.Fields[i].FieldName;if cxtvMaster.DataController.DataSet.Fields[i] is TNumericField then beginTNumericField(cxtvMaster.DataController.DataSet.Fields[i]).DisplayFormat := '#,##0.00';cl.Width := 80;with TcxGridDBTableSummaryItem(cxtvMaster.DataController.Summary.FooterSummaryItems.Add) dobeginColumn := cl;FieldName := cl.DataBinding.FieldName;Format := '#,##0.00';Kind := skSum;end;endelse if cxtvMaster.DataController.DataSet.Fields[i] is TStringField thencl.Width := 100elsecl.Width := 80;cl.HeaderAlignmentHorz := taCenter;end; //iffinallycxtvMaster.EndUpdate;Screen.Cursor := crDefault;end;end;3.动态生成TcxGridDBBandedTableView的列及页脚的合计栏日期: 2004-1-10 17:24:32如果存储过程或SQL返回如下结果集员工 1月$ 1月, 2月$ 2月, 合计$ 合计,------------------------------------------- 测试员A 200 1658 300 2487 500 4145将生成如下样式的Grid(页脚没有画出,麻烦,另外设置了显示格式,金额将以#,##0.00的方式显示)_________________________________________________ | 员工 | 1月 | 2月 | 合计 ||-----------------------------------------------| | 员工 | , | , | , | , | , | , ||-----------------------------------------------| |测试员A | 200 | 1658 | 300 | 2487 | 500 | 4145 | -------------------------------------------------vari : Integer;cl : TcxGridDBBandedColumn;beginScreen.Cursor := crHourGlass;cxbtvMaster.BeginUpdate;trycxbtvMaster.ClearItems;cxbtvMaster.Bands.Clear;cxbtvMaster.DataController.Summary.FooterSummaryItems.Clear;for i := 0 to cxbtvMaster.DataController.DataSet.FieldCount - 1 do beginif i = 0 thenwith cxbtvMaster.Bands.Add dobeginOptions.HoldOwnColumnsOnly := True;Caption := cxbtvMaster.DataController.DataSet.Fields[i].FieldName; end;if RightStr(cxbtvMaster.DataController.DataSet.Fields[i].FieldName,1) = '$' thenwith cxbtvMaster.Bands.Add dobeginOptions.HoldOwnColumnsOnly := True;Caption := Copy(cxbtvMaster.DataController.DataSet.Fields[i].FieldName, 1,Length(cxbtvMaster.DataController.DataSet.Fields[i].FieldName) - 1);cxbtvMaster.DataController.DataSet.Fields[i].DisplayLabel := ',';end;if RightStr(cxbtvMaster.DataController.DataSet.Fields[i].FieldName,1) = ',' thencxbtvMaster.DataController.DataSet.Fields[i].DisplayLabel := ',';cl := cxbtvMaster.CreateColumn;cl.HeaderAlignmentHorz := taCenter;cl.Position.BandIndex := cxbtvMaster.Bands.Count - 1;cl.DataBinding.FieldName :=cxbtvMaster.DataController.DataSet.Fields[i].FieldName;if cxbtvMaster.DataController.DataSet.Fields[i] is TNumericField thenbeginTNumericField(cxbtvMaster.DataController.DataSet.Fields[i]).DisplayFormat := '#,##0.00';cl.Width := 80;with TcxGridDBBandedTableSummaryItem(cxbtvMaster.DataController.Summary.FooterSummaryItems.Add) dobeginColumn := cl;FieldName := cl.DataBinding.FieldName;Format := '#,##0.00';Kind := skSum;end;endelse if cxbtvMaster.DataController.DataSet.Fields[i] is TStringField thencl.Width := 100elsecl.Width := 80;end; //iffinallycxbtvMaster.EndUpdate;Screen.Cursor := crDefault;end;end;4.自动调整列宽的方法要注意的地方2004-1-31 22:36:25可以用ApplyBestFit实现自动列宽;不能在BeginUpdate和EndUpdate之间调用这个方法,否则会产生下标越界错误; 在BeginUpdate和EndUpdate中清除/建立列不会产生屏幕闪烁,其它需要长时间更新cxGrid数据的操作最好放在BeginUpdate和EndUpdate执行,并用try包起来.5.DevExpress Bar的动态菜单2004-2-8 15:32:30没有什么说明,细心点应该知道表结构及数据的内容形式对比了一下代码,用dxBar比用ToolBar+PopupMenu生成动态菜单要简单,只用了一个递归过程type//菜单项PMenuItemInfo = ^TMenuItemInfo;TMenuItemInfo = recordID : string;ParentID : string;Caption : string;Hint : string;LibraryName : string;ProcedureName : string;wParam : Integer;lParam : Integer;end;procedure TmgMainForm.BuildMenu; //生成菜单procedure SetMenuItemInfo(const ADataSet : TDataSet;const AItem : PMenuItemInfo);beginAItem.ID := ADataSet.FieldByName('ID').AsString;AItem.ParentID := ADataSet.FieldByName('ParentID').AsString;AItem.Caption := ADataSet.FieldByName('Caption').AsString;AItem.Hint := ADataSet.FieldByName('Hint').AsString;AItem.LibraryName := ADataSet.FieldByName('LibraryName').AsString;AItem.ProcedureName :=ADataSet.FieldByName('ProcedureName').AsString;AItem.wParam := ADataSet.FieldByName('wParam').AsInteger;AItem.lParam := ADataSet.FieldByName('lParam').AsInteger;end;procedure CreateItemList(const ADataSet : TDataSet;const AList : TList;const AText : string);//根据父节点建立子项目列表varm : PMenuItemInfo;i : Integer;beginADataSet.First;for i := 0 to ADataSet.RecordCount - 1 dobeginif ADataSet.FieldByName('ParentID').AsString = AText thenbeginNew(m);SetMenuItemInfo(ADataSet,m); AList.Add(m);ADataSet.Delete;end elseADataSet.Next;end; //forend;procedure CreateMenuItems(const ADataSet : TDataSet;const AKeyValue : string;const AItemLinks : TdxBarItemLinks; const AIndex : Integer);//建立菜单项vardb : TdxBarButton;dbs : TdxBarSubItem;l : TList;i : Integer;j : Integer;bg : Boolean;beginbg := False;j := AIndex;l := TList.Create;tryCreateItemList(ADataSet, l, AKeyValue);for i := 0 to l.Count - 1 dobeginif ADataSet.Locate('ParentID', PMenuItemInfo(l[i]).ID, []) then begin//有子项dbs := TdxBarSubItem.Create(dxBar);dbs.Caption := PMenuItemInfo(l[i]).Caption;dbs.Hint := PMenuItemInfo(l[i]).Hint;dbs.Tag := Integer(l[i]);if AIndex > 0 thendbs.ImageIndex := 0;with AItemLinks.Add dobeginItem := dbs;Index := j;BeginGroup := bg;end; //withbg := False;CreateMenuItems(ADataSet, PMenuItemInfo(l[i]).ID, dbs.ItemLinks, 0); if dbs.ItemLinks.Count = 0 thendbs.FreeelseInc(j);endelse begin//无子项if not (PMenuItemInfo(l[i]).Caption = '-') then begindb := TdxBarButton.Create(dxBar);db.Caption := PMenuItemInfo(l[i]).Caption;db.Hint := PMenuItemInfo(l[i]).Hint;db.Tag := Integer(l[i]);db.OnClick := MenuItemClick;if AIndex > 0 thendb.ImageIndex := 0;with AItemLinks.Add dobeginItem := db;Index := j;BeginGroup := bg;end;bg := False;Inc(j);endelse beginbg := True;end; //if bgend; //if Locateend; //forfinallyl.Free;end;end;varrsMenus : TDataSet;beginrsMenus := mgDMMain.GetMenus; //取得数据集if Assigned(rsMenus) thentryCreateMenuItems(rsMenus, '', dxBar.Bars[0].ItemLinks, 1); //一定要刷新一下,否则不更改样式会出错dxBar.Bars[0].ItemLinks[0].Visible := False;dxBar.Bars[0].ItemLinks[0].Visible := True;finallyrsMenus.Free;end;end;6. 取得TcxLookupComboBox下拉列表中各项的内容日期: 2005-1-416:34:35Properties.DataController.Values包含了所有内容,如果要取得当前选择行的内容,用以下代码 //cmb:TcxLookupComboBox;with cmb.Properties.DataController doShowMessage(Values[FindRecordIndexByKey(cmb.EditValue),0]);//0代表显示的第一列,以Properties.ListColumns为准,可以从这个集合中查找对应的字段名三、。
DEV中的treelist使用方法

treeDevice.Columns["dID"].Caption = "类别"; treeDevice.Columns["dType"].Caption = "别名"; 注意:必须得绑定字段
//中间插入节点 private void treeList2_CellValueChanged(object sender, DevExpress.XtraTreeList.CellValueChangedEventArgs e)//单元已有值就会增添一条空 信息 { string name = e.Node.GetDisplayText(0); if (name != "") { TreeListNode node = treeList2.AppendNode(new object[] { "" }, -1);
/// <summary> /// 最后选择的节点
/// </summary> TreeListNode deletenode; private void treeList1_AfterFocusNode(object sender, DevExpress.XtraTreeList.NodeEventArgs e) { deletenode =e.Node; //获取最后的 ID } public void btnDel_Click(object sender, EventArgs e) { this.treeList1.DeleteNode(deletenode); //删除节点 }
dev 中 TreeList 的应用
如果需要在单元格添加时则用 TreeList 如果只是单纯读取数据或检索数据时则用 GridControl
DEV的TreeList添加ToolTip信息

DEV的TreeList添加ToolTip信息您可以使⽤ToolTipController控件,然后通过事件来设置ToolTip关键代码:private void toolTipController1_GetActiveObjectInfo(object sender, DevExpress.Utils.ToolTipControllerGetActiveObjectInfoEventArgs e){if (e.SelectedControl is DevExpress.XtraTreeList.TreeList){TreeList tree = (TreeList)e.SelectedControl;TreeListHitInfo hit = tree.CalcHitInfo(e.ControlMousePosition);if (hit.HitInfoType == HitInfoType.Cell){object cellInfo = new TreeListCellToolTipInfo(hit.Node, hit.Column, null);string toolTip = string.Format("{0} (Column: {1}, Node ID: {2})", hit.Node[hit.Column],hit.Column.VisibleIndex, hit.Node.Id); = new DevExpress.Utils.ToolTipControlInfo(cellInfo, toolTip);}}}本⼈树形列表只有⼀列值,树形数据为⼀级区域,⼆级⼦区域,三级设备,⽽提⽰信息只要三级设备提⽰连接状态使⽤TreeList的节点的Tag值作为提⽰信息值,只在TreeList绑定值事件中添加三级设备的节点的tag值,并修改事件中部分代码 if (hit.HitInfoType == HitInfoType.Cell){if (hit.Node.Tag == null) return;object cellInfo = new TreeListCellToolTipInfo(hit.Node, hit.Column, null);string toolTip = string.Format("{0}", hit.Node.Tag.ToString()); = new DevExpress.Utils.ToolTipControlInfo(cellInfo, toolTip);} 即可以使⼀⼆级节点不显⽰ToolTip,三级节点显⽰ToolTip 。
DevExpress基本控件讲解

谢 谢!
图表控件(Chart)
各种图表种类齐全. 条形图、线形图、饼图、点状图、环形图、雷达图、面积图、甘特图, 3D效果 图表的DEMO
综合性示例
我们来欣赏一下DevExpress控件在一个实际项目中的综合应用. 该示例以一个影碟租售店的销售管理作为应用的场景. 查看示例
树控件
树控件的主要功能
以网格结构显示树型数据,可以显示多列数据 和网格控件一样,可以单击列标头排序 和网格控件一样,有即点即输的编辑功能 内置拖放结点操作 树控件的DEMO演示
工具栏及导航控件
DevExpress的工具栏及导航控件完全取代了.net framework自带的一 系列相似功能的标准控件,功能更为强大,使用更加灵活.并有多种皮 肤和样式可供选择. 侧边栏导航(NavBar):有Outlook样式、XP样式 DEMO演示 菜单栏和工具栏 DEMO演示
DevExpress基本控件讲解
为产品规划部而作
控件按使用的技术平台的分类
WINFROM WPF Silverlight 目前.net开发小组用的是WINFORM系列的控件.
WINFROM控件系列
中文名称 网格(表格) 树 工具栏及导航 日历 富文本编辑 图表
网格控件的主要功能
多种视图(网格、卡片、阵列) 丰富的格式控制(复合表头、合并单元格线条、背景、字体、高亮、 条件格式…) 主从表(Master-Detail)关联数据的展示 对列进行分组 内置排序和汇总的功能 内含对搜索和筛选的支持 在线编辑、插入、删除的功能 网格控件的演示
富文本编辑控件(RichEditor)
完全模仿Word的富文本编辑控件. 支持多种格式:Word2003/2007,Rtf,Html,纯文本,PDF(只能导出) 丰富的格式控制。 邮件合并:在文档中预留特殊标记,在程序中自动用内容替换这些标 记。可做到批量处理。 主要的缺点 :不支持浮动的排版元素 (有可能在下一个版本会改进) 日程表的DEMO
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
devexpresstreelist的用法
一、概述
DevExpressTreelist控件是一款强大的TreeList控件,它提供了丰富的功能和灵活的配置选项,可以方便地展示和管理列表数据。
在DevExpress控件库中,Treelist控件适用于各种应用程序,如项目管理、文件系统、数据库管理等。
二、基本用法
1.添加控件到窗体:在窗体设计器中,将DevExpressTreelist控件拖放到窗体上。
2.配置数据源:使用Treelist控件的数据源属性,设置要展示的数据。
可以连接数据库、读取数据文件或使用数据集对象作为数据源。
3.配置列:通过设置列属性,可以自定义列的显示方式、排序规则和数据类型。
4.展开和折叠节点:使用鼠标或键盘,可以展开和折叠TreeList控件中的节点,以查看更多细节。
5.搜索和过滤:Treelist控件提供了搜索和过滤功能,可以快速定位所需数据。
三、常用操作
1.添加和删除节点:可以使用手动方式或编程方式,添加和删除TreeList控件中的节点。
2.编辑节点数据:在TreeList控件中选中节点后,可以编辑节点的数据。
3.复制和移动节点:可以使用复制和移动功能,方便地复制和转移节点。
4.排序和筛选:通过设置排序规则和筛选条件,可以按照指定方式展示TreeList控件中的数据。
四、高级用法
1.自定义外观:通过设置TreeList控件的外观属性,可以自定义节点的样式、颜色、字体等。
2.实现自定义操作:可以使用事件处理程序或编程方式,实现自定义的操作,如节点展开时的动画效果、节点的拖拽和放置等。
3.集成其他控件:可以将Treelist控件与其他DevExpress控件集成,实现更复杂的功能和界面。
五、示例代码
以下是一个简单的示例代码,展示如何使用DevExpressTreelist控件展示数据:
```csharp
//创建TreeList控件并设置数据源
TreeList1.DataSource=myDataSet;
//配置列属性
TreeList1.Columns["Column1"].Visible=true;
TreeList1.Columns["Column2"].Visible=false;
TreeList1.Columns["Column3"].DataFormatString="integer";
//展开节点时执行自定义操作
TreeList1.BeginInit();
TreeList1.Nodes["Node1"].BeginEdit();
TreeList1.Events.NodeAfterCheck+=newDevExpress.XtraTreeList.NodeAft erCheckEventHandler(TreeList1_NodeAfterCheck);
TreeList1.EndInit();
//实现自定义操作代码
voidTreeList1_NodeAfterCheck(objectsender,DevExpress.XtraTreeList.N odeAfterCheckEventArgse)
{
//处理节点选中事件,根据需要执行相应操作
}
```
六、总结
DevExpressTreelist控件是一款功能强大的TreeList控件,提供了丰富的功能和灵活的配置选项。
通过基本用法、常用操作和高级用法的学习,可以更好地掌握DevExpressTreelist控件的使用方法。
同时,示例代码可以帮助您更好地理解和应用相关知识。