dev常用

 

  1. 1.TextEditor(barEditItem)取文本   
  2.   
  3. string editValue = barEditItem1.EditValue.ToString();    //错误,返回null   
  4.    
  5. string editValue = ((DevExpress.XtraEditors.TextEdit)barEditItem).EditValue.ToString();    //正确,返回文本框内容   
  6.   
  7. 2.ComboBoxEdit(barEditItem)添加Item   
  8.   
  9. string item = "comboboxItem1";  
  10. ((DevExpress.XtraEditors.Repository.RepositoryItemComboBox)this.barEditItem.Edit).Items.Add(item);  
  11.   
  12. 3.ComboBoxEdit(barEditItem)取文本   
  13.   
  14. string itemValue = this.barEditItem.EditValue.ToString();  
  15.   
  16. 4.Ribbon控件   
  17.   
  18. //添加Page   
  19. DevExpress.XtraBars.Ribbon.RibbonPage ribbonPage = new RibbonPage();  
  20. ribbonControl.Pages.Add(ribbonPage);  
  21. //添加Group   
  22. DevExpress.XtraBars.Ribbon.RibbonPageGroup ribbonPageGroup = new RibbonPageGroup();  
  23. ribbonPage.Groups.Add(ribbonPageGroup);  
  24. //添加Button   
  25. DevExpress.XtraBars.BarButtonItem barButtonItem = new BarButtonItem();  
  26. ribbonPageGroup.ItemLinks.Add(barButtonItem);  
  27. //添加barSubItem   
  28. DevExpress.XtraBars.BarSubItem barSubItem = new BarSubItem();  
  29. ribbonPageGroup.ItemLinks.Add(barSubItem);  
  30. //barSubItem下添加Button   
  31. barSubItem.AddItem(barButtonItem);  
  32.    
  33.    
  34. //奇怪的删除Page问题   
  35. while (this.ribbonControl.Pages.Count > 0)  
  36. {  
  37.      ribbonControl.Pages.Remove(ribbonControl.Pages[0]);    //调试正常,运行报异常   
  38. }  
  39. while (this.ribbonControl.Pages.Count > 0)  
  40. {  
  41.      ribbonControl.SelectedPage = ribbonControl.Pages[0];  
  42.      ribbonControl.Pages.Remove(ribbonControl.SelectedPage); //运行正常   
  43. }  
  44. //禁止F10键Tips   
  45. ribbonControl.Manager.UseF10KeyForMenu = false;  
  46. //DX按钮   
  47. ApplicationIcon属性改变图标  
  48. 右键 Add ApplicationMenu 添加evExpress.XtraBars.Ribbon.ApplicationMenu  
  49.   
  50. 5.HitInfo   
  51.   
  52. //在Tab页上点击右键的事件响应   
  53. void xtraTabbedMdiManager_Event(object sender, MouseEventArgs e)  
  54. {  
  55.      if (e.Button == MouseButtons.Right && ActiveMdiChild != null)  
  56.      {  
  57.           DevExpress.XtraTab.ViewInfo.BaseTabHitInfo hInfo = xtraTabbedMdiManager.CalcHitInfo(e.Location);  
  58.           //右键点击位置:在Page上且不在关闭按钮内   
  59.           if (hInfo.IsValid && hInfo.Page != null && !hInfo.InPageCloseButton)  
  60.           {  
  61.                this.popupMenu.ShowPopup(Control.MousePosition);//在鼠标位置弹出,而不是e.Location   
  62.           }  
  63.      }  
  64. }  
  65. //在ribbon上点击右键的事件响应   
  66. private void ribbonControl1_ShowCustomizationMenu(object sender, RibbonCustomizationMenuEventArgs e)  
  67. {  
  68.     //禁掉原系统右键菜单   
  69.     e.ShowCustomizationMenu = false;  
  70.     //右键位置:在barButtonItem上   
  71.     if (e.HitInfo != null   
  72.      && e.HitInfo.InItem  
  73.      && e.HitInfo.Item.Item is BarButtonItem)  
  74.     {  
  75.          this.popupMenu.ShowPopup(Control.MousePosition);  
  76.     }  
  77.     //右键位置:在barSubItem中的barButtonItem上   
  78.     else if (e.Link != null   
  79.           && e.Link.Item != null   
  80.           && e.Link.Item is BarButtonItem)  
  81.     {  
  82.          this.popupMenu.ShowPopup(Control.MousePosition);  
  83.     }  
  84. }  
  85.   
  86. 6.皮肤   
  87.   
  88. //添加皮肤程序集后注册皮肤   
  89. DevExpress.UserSkins.OfficeSkins.Register();  
  90. DevExpress.UserSkins.BonusSkins.Register();  
  91. //设置皮肤   
  92. DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle("Liquid Sky");    //若皮肤名称错误则按系统默认设置(第一个皮肤)   
  93. //GalleryFilterMenuPopup事件设置弹出筛选菜单的“All Groups”为中文   
  94. private void rgbiSkins_GalleryFilterMenuPopup(object sender, GalleryFilterMenuEventArgs e)  
  95. {  
  96.     e.FilterMenu.ItemLinks[n].Caption = "所有皮肤";    //n=分组数+1   
  97. }  
  98. //GalleryInitDropDownGallery事件设置弹出皮肤列表的表头“ALL Groups”为中文   
  99. private void rgbiSkins_GalleryInitDropDownGallery(object sender, InplaceGalleryEventArgs e)  
  100. {  
  101.     e.PopupGallery.FilterCaption = "所有皮肤";  
  102. }  
  103.   
  104. 7.dockManager   
  105.   
  106. 将视图的状态信息保存到xml文件  
  107. dockManager1.SaveLayoutToXml("..//UserConfig//ViewInfo.xml");  
  108. 导出xml中保存的状态信息  
  109. dockManager1.RestoreLayoutFromXml("..//UserConfig//ViewInfo.xml");  
  110.   
  111. 8.barManager   
  112.   
  113. 设置bar的字体与系统字体  
  114. barAndDockingController1.AppearancesBar.ItemsFont = new Font(this.Font.FontFamily, currentFontSize);  
  115.   
  116. 9.设置系统字体   
  117.   
  118. DevExpress.Utils.AppearanceObject.DefaultFont = new Font(this.Font.FontFamily, currentFontSize);  
  119.   
  120. 10.treeView   
  121.   
  122. 为tree节点加右键菜单并选中该节点  
  123.         private void treeList1_MouseDown(object sender, MouseEventArgs e)  
  124.         {  
  125.             if (e.Button == MouseButtons.Right)  
  126.             {  
  127.                 DevExpress.XtraTreeList.TreeListHitInfo hi = treeList1.CalcHitInfo(e.Location);  
  128.                 if (hi.Node != null && hi.Node.ImageIndex == 5) //叶子节点的ImageIndex == 5   
  129.                 {  
  130.                     TreeListNode node = treeList1.FindNodeByID(hi.Node.Id);  
  131.                     treeList1.FocusedNode = node;  
  132.    
  133.                     this.popupMenu1.ShowPopup(MousePosition);  
  134.                 }  
  135.             }  
  136.         }  

 

posted @ 2012-08-07 10:40  咸鱼公子  Views(2546)  Comments(0Edit  收藏  举报