. net_devexpress Control Use Experience Summary

Source: Internet
Author: User

DevExpress Control Use Experience Summary
DevExpress is a relatively well-known interface control suite that provides a series of interface controls for the Dotnet interface Control suite. This article mainly describes some of the problem solutions that I encountered or found during the process of using the DevExpress control, or I can also show some small experience summaries. In general, the use of DevExpress controls allows for more efficient interface design and more aesthetic results. This article mainly by giving the corresponding example and the relevant interface effect to illustrate the problem, I hope we can get good knowledge and ideas.

1, the application of Office2007 and Office2010 interface theme

When you start using devexpress, you find that the program interface effect doesn't appear to be the style of office, just a few poor built-in effects. After finding the discovery you need to add a few lines of code inside the entry function, as shown below.

DevExpress.UserSkins.OfficeSkins.Register ();
DevExpress.UserSkins.BonusSkins.Register ();
DevExpress.Skins.SkinManager.EnableFormSkins ();
Specifies the interface theme effect, which can be set by code, specifying the name of the subject.

UserLookAndFeel.Default.SetSkinStyle ("Office Blue");

Or add a control in the interface Defaultlookandfeel, set its corresponding interface effect can achieve the entire design time and run time of the interface effect, as shown in.

2, Properties property

DevExpress The general properties of many controls, which are placed under this property, such as the properties of the ComboBox drop-down list are as follows

private void Initdictitem ()
This.txtManufacture.Properties.Items.Clear ();
This.txtManufacture.Properties.Items.AddRange (Dictitemutil.getdictbydicttype ("supplier"));

This is a very rich attribute of the collation, a lot of common properties are basically included here, if you are from the traditional interface to convert from the Devexperss development, find the relevant properties, although come here to see. For example, set the visibility, availability,

Custom display formats, and so on.

3, the GridView related operations

Gets the contents of the selected row-making column, and the operation code to delete the record is as follows

The devexpess GridView control, unlike the traditional winfrom gridview, is very different, such as he does not getselectedrow the rowset operation, but can be obtained by getselectedrows the established row ordinal, The operation is done by the row ordinal, such as to get the specified row, to make the contents of the column, you can get the text by Getrowcelldisplaytext or get the corresponding value by Getrowcellvalue.

If you need to get the data for the columns of the currently selected row (in which the focus is in the row), you can get it through the function getfocusedrowcelldisplaytext ("ID").

private void Wingridviewpager1_ondeleteselected (object sender, EventArgs e)
if (Messageutil.showyesnoandtips ("Are you sure to delete the selected records?") ") = = dialogresult.no)

int[] rowselected = This.winGridViewPager1.GridView1.GetSelectedRows ();
foreach (int iRow in rowselected)
String id = this.winGridViewPager1.GridView1.GetRowCellDisplayText (iRow, "ID");
Bllfactory<itemdetail>. Instance.delete (ID);
Binddata ();

For the GridView row to prompt information and display line numbers, sometimes in order to facilitate the display of data, you need to display the column's row information and line numbers in the first column of the GridView, then you need to add a Tooltipcontroller control for the GridView control. Then implement the control's Getactiveobjectinfo event, add the following code in the event, and implement the GridView control's Customdrawrowindicator event, as shown in the following code.

private void Tooltipcontroller1_getactiveobjectinfo (object sender, DevExpress.Utils.ToolTipControllerGetActiveObjectInfoEventArgs e)
if (E.selectedcontrol! = gridControl1) return;

Tooltipcontrolinfo info = null;
Get The view at the current mouse position
GridView view = Gridcontrol1.getviewat (e.controlmouseposition) as GridView;
if (view = = null) return;

Get The view ' s element information that resides at the current position
Gridhitinfo hi = view. Calchitinfo (e.controlmouseposition);
Display a hint for row indicator cells
if (hi. HitTest = = gridhittest.rowindicator)
An object that uniquely identifies a row indicator cell
Object o = Hi. hittest.tostring () + hi. Rowhandle.tostring ();
StringBuilder sb = new StringBuilder ();
Sb. Appendline ("line data basic information:");
foreach (GridColumn gridcol in view. Columns)
if (gridcol.visible)
Sb. AppendFormat ("{0}:{1}\r\n", gridcol.caption, view.) Getrowcelldisplaytext (hi. Rowhandle, Gridcol.fieldname));
info = new Tooltipcontrolinfo (o, sb.) ToString ());

Supply ToolTip Information if applicable, otherwise preserve default tooltip (if any)
if (info! = null)
E.info = Info;

private void Gridview1_customdrawrowindicator (object sender, Rowindicatorcustomdraweventargs e)
if (Showlinenumber)
E.appearance.textoptions.halignment = DevExpress.Utils.HorzAlignment.Far;
if (e.info.isrowindicator)
if (e.rowhandle >= 0)
E.info.displaytext = (E.rowhandle + 1). ToString ();

Although the above is using my devexpress pagination control, the inside of the page control is not over the devexpress of the Gridcontrol control.

4, common layout control.

Traditional data editing interface, we generally need to add a label, and then add a TextBox or other controls, and devexpress in this area is really a lot of effort, introduced a Layoutcontrol control, The control will automatically add a label-like control to you when adding another control such as a TextBox, and the layout has been aligned to your design, adding several columns of controls that can be placed on a single line, and the alignment effect is very good, if you re-design the interface, Saves a lot of alignment and maintains label properties.

In addition, the layout property can set a boundary effect similar to GroupBox (the default does not display text and boundaries), or it can uniformly design the effects of various controls inside the layout control, such as how the display of ReadOnly is true, how to display the Enable false, and only one place to set , you can unify the interface effect. In short, it is quite good to use.

Generally speaking, the first use of devexpress will feel that many places are not suitable, and sometimes can not find the corresponding properties, but when slowly familiar with the use of the control to develop, it will feel that it does introduce a good idea in many places, accustomed to feel that efficiency has improved a lot, The interface design will also feel more beautiful and convenient. As I am only a small example of my usual development, as well as my WinForm development framework, the application of the DevExpress control of a variety of common effects, there should be a lot of common controls and advanced controls are not used, and later continue to use, will continue to record the corresponding experience for everyone to discuss.

Finally, I attach an interface that I applied the devexpress control to improve the WinForm development framework, which is applied to the Ribbon interface effect and the paging control based on the DevExpress control (as described in the previous example), using the pagination control. For the entire GridView processing, will be more convenient, the interface effect is as follows.

. net_devexpress Control Use Experience Summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.