The GridControl control of DevExpress sets the custom display method, devexpress
For example, to display gender as a string, the database is saved as a value (1: male, 2: female, 3: Unknown ).
Method 1:
Click the "Run Designer" button on the control to go to the design page.
Select Columns to add a hidden field. The field value is the bound value to be displayed. If gender is displayed, bind the "Sex" field.
Add a display field, which is a field display expression.
The value of UnboundExpression is: Iif ([SexExpression] <= 2 And [SexExpression]> 0, Iif ([SexExpression] = 1, 'male', 'female '), unknown ').
Modify the value of the UnboundType attribute to String.
Set the attribute FiledName to SexDesc.
Method 2:
Click the "Run Designer" button on the control to go to the design page.
Edit the GridView1 event CustomColumnDisplayText of Views.
Private void gridView1_CustomColumnDisplayText (object sender, DevExpress. XtraGrid. Views. Base. CustomColumnDisplayTextEventArgs e) {if (e. Column. FieldName = "Sex") {if (e. Value! = Null) {switch (e. value. toString (). trim () {case "1": e. displayText = "male"; break; case "2": e. displayText = "female"; break; case "3": e. displayText = "unknown"; break; default: e. displayText = ""; break ;}}}}
How to save settings when selecting custom GridControlGridView columns in DevExpress and displaying/hiding columns so that the columns displayed next time are consistent
It must be stored in the database. I don't know about winform, but the web uses LoadClientLayout.
How to customize the title of a third-pole table using the Devexpress control GridControl