DevExpress is very popular. NET Control, which is currently used by many users around the world and in China. However, because it is in English, it may be difficult for first-time contacts. Here we will summarize the 10 common usage skills of DevExpress.
1. TextEditor (barEditItem) takes the text
String editValue = barEditItem1.EditValue. ToString (); // error, return null
String editValue = (DevExpress. XtraEditors. TextEdit) barEditItem). EditValue. ToString (); // precise, return the DevExpress usage tips
2. ComboBoxEdit (barEditItem) Add Item
String item = "comboboxItem1 ";
(DevExpress. XtraEditors. Repository. RepositoryItemComboBox) this. barEditItem. Edit). Items. Add (item );
3. ComboBoxEdit (barEditItem) takes the text
String itemValue = this. barEditItem. EditValue. ToString ();
4. Ribbon Control
// Add Page
DevExpress. XtraBars. Ribbon. RibbonPage ribbonPage = new RibbonPage ();
RibbonControl. Pages. Add (ribbonPage );
// Add a Group
DevExpress. XtraBars. Ribbon. RibbonPageGroup ribbonPageGroup = new RibbonPageGroup ();
RibbonPage. Groups. Add (ribbonPageGroup );
// Add a Button
DevExpress. XtraBars. BarButtonItem barButtonItem = new BarButtonItem ();
RibbonPageGroup. ItemLinks. Add (barButtonItem );
// Add barSubItem
DevExpress. XtraBars. BarSubItem barSubItem = new BarSubItem ();
RibbonPageGroup. ItemLinks. Add (barSubItem );
// Add a Button under barSubItem
BarSubItem. AddItem (barButtonItem );
// Strange Page deletion problem (DevExpress Tips)
While (this. ribbonControl. Pages. Count> 0)
{
RibbonControl. Pages. Remove (ribbonControl. Pages [0]); // The debugging is normal and an exception is reported during running.
}
While (this. ribbonControl. Pages. Count> 0)
{
RibbonControl. SelectedPage = ribbonControl. Pages [0];
RibbonControl. Pages. Remove (ribbonControl. SelectedPage); // normal operation
}
// Curb the F10 Key Tips (DevExpress Tips)
RibbonControl. Manager. UseF10KeyForMenu = false;
// DX button
ApplicationIcon attribute change icon
Right-click Add ApplicationMenu to Add evExpress. XtraBars. Ribbon. ApplicationMenu5.HitInfo
// Right-click the work response on the Tab (DevExpress Tips)
Void xtraTabbedMdiManager_Event (object sender, MouseEventArgs e)
{
If (e. Button = MouseButtons. Right & ActiveMdiChild! = Null)
{
DevExpress. XtraTab. ViewInfo. BaseTabHitInfo hInfo = xtraTabbedMdiManager. CalcHitInfo (e. Location );
// Right-click position: on the Page and not in the close button
If (hInfo. IsValid & hInfo. Page! = Null &&! HInfo. InPageCloseButton)
{
This. popupMenu. ShowPopup (Control. MousePosition); // The cursor is displayed, instead of e. Location.
}
}
}
// Right-click the work response on ribbon
Private void ribbonControl1_ShowCustomizationMenu (object sender, RibbonCustomizationMenuEventArgs e)
{
// Disable the context menu of the original system
E. ShowCustomizationMenu = false;
// Right-click on barButtonItem
If (e. HitInfo! = Null
& Amp; e. HitInfo. InItem
& E. HitInfo. Item. Item is BarButtonItem)
{
This. popupMenu. ShowPopup (Control. MousePosition );
}
// Right-click the position on the barButtonItem
Else if (e. Link! = Null
& Amp; e. Link. Item! = Null
& E. Link. Item is BarButtonItem)
{
This. popupMenu. ShowPopup (Control. MousePosition );
}
}
6. Skin
// Register the skin after adding the skin rail category set (DevExpress Tips)
DevExpress. UserSkins. OfficeSkins. Register ();
DevExpress. UserSkins. BonusSkins. Register ();
// Set skin
DevExpress. LookAndFeel. UserLookAndFeel. Default. SetSkinStyle ("Liquid Sky"); // if the title of the skin is incorrect, set it as the Default one (the first skin)
// GalleryFilterMenuPopup work settings
Private void rgbiSkins_GalleryFilterMenuPopup (object sender, GalleryFilterMenuEventArgs e)
{
E. FilterMenu. ItemLinks [n]. Caption = "all skins"; // n = number of groups + 1
}
// GalleryInitDropDownGallery settings
Private void rgbiSkins_GalleryInitDropDownGallery (object sender, InplaceGalleryEventArgs e)
{
E. PopupGallery. FilterCaption = "all skins ";
}
7. dockManager
Store View status information to an xml file
DockManager1.SaveLayoutToXml (".. \ UserConfig \ ViewInfo. xml ");
Export the status information stored in xml
DockManager1.RestoreLayoutFromXml (".. \ UserConfig \ ViewInfo. xml ");
8. barManager
Set the font and system font of bar
BarAndDockingController1.AppearancesBar. ItemsFont = new Font (this. Font. FontFamily, currentFontSize );
9. Set the system font
DevExpress. Utils. AppearanceObject. DefaultFont = new Font (this. Font. FontFamily, currentFontSize );
10. treeView
Right-click the tree node and select the node
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) // The ImageIndex of the leaf Node = 5
{
TreeListNode node = treeList1.FindNodeByID (hi. Node. Id );
TreeList1.FocusedNode = node;
This. popupMenu1.ShowPopup (MousePosition );
}
}
}
---------------------------------------------------
DevExpress DXperience is.. NET Control package, IDE report generation tool, and enterprise application framework. DXperience helps Chinese software enterprises develop many excellent software products, DXperience. Its brand and quality are globally recognized.
Except for the reposted content, this site is original or translated.
You are welcome to repost it in any form, but be sure to indicate the source and respect others' labor achievements
Reprint Please note: Article Reprinted from: DevExpress Control Chinese network [http://www.devexpresscn.com/]
Address: http://www.devexpresscn.com/news/news-88.html