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.Edi t).Items.Add(item); 3.ComboBoxEdit(barEditItem) 取文本 string itemValue = this.barEditItem.EditValue.ToString(); 4.Ribbon 控件 // 添加 Page DevExpress.XtraBars.Ribbon.RibbonPageribbonPage = new RibbonPage(); ribbonControl.Pages.Add(ribbonPage); // 添加 Group DevExpress.XtraBars.Ribbon.RibbonPageGroupribbonPageGroup = new RibbonPageGroup(); ribbonPage.Groups.Add(ribbonPageGroup); // 添加 Button DevExpress.XtraBars.BarButtonItembarButtonItem = new BarButtonItem(); ribbonPageGroup.ItemLinks.Add(barButtonItem); // 添加 barSubItem DevExpress.XtraBars.BarSubItembarSubItem = 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.BaseTabHitInfohInfo = 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); } } }