GridControl is bound to a non-bound column, and gridcontrol is bound to a non-bound column.
1. Set FieldName of a non-bound column;
2. Modify the UnboundType attribute, except for the default bound (but if the Boolean type is not selected, only one check box is displayed and NO content is displayed)
3. Bind The gridView munboundcolumndata event of the gridView
4. Finally, bind non-bound columns in the CustomUnboundColumnData event. The Code is as follows:
Private void gridview1_munmunboundcolumndata (object sender, DevExpress. XtraGrid. Views. Base. CustomColumnDataEventArgs e) {if (e. Column. FieldName = "Column name" & e. IsGetData)
{
E. Value = Value
}
}
The following is the sample code:
// Set a globally unique FieldName in the form for the non-Bind Column colAB
String colClassAndCount = "ClassAndCount"; // create the test data table public static class ServiceData {public static DataTable GetClassCount () {DataTable dt = new DataTable (); dt. columns. add ("class", typeof (string); // grade dt. columns. add ("count", typeof (int); // dt. rows. add ("First Year", 120); dt. rows. add ("Grade 2", 180); dt. rows. add ("Grade 3", 890); dt. rows. add ("Grade 4", 108); dt. rows. add ("Grade 5", 280); dt. rows. add ("", 320); dt. rows. add ("Grade 7", 450); dt. rows. add ("eighth graders", 410); dt. rows. add ("ninth grade", 230); return dt ;}// bind private void gridView_CustomUnboundColumnData (object sender, DevExpress. xtraGrid. views. base. customColumnDataEventArgs e) {DataView dv = ServiceData. getClassCount (). defaultView; if (e. isGetData) {// set the FieldName of the non-bound column to the defined global FieldName, // match the FieldName of each column in The gridView // set the colAB display content of the non-bound column: class + Count if (e. column. fieldName = colClassAndCount) {string classNo = dv [e. listSourceRowIndex] ["class"]. toString (); string countNum = dv [e. listSourceRowIndex] ["count"]. toString (); string ClassAndCount = classNo + "+" + countNum; e. value = ClassAndCount ;}} private void Form5_Load (object sender, EventArgs e) {gridControl3.DataSource = ServiceData. getClassCount ();}
The final result is as follows: