GridControl is bound to a non-bound column, and gridcontrol is bound to a non-bound column.

Source: Internet
Author: User

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:

  

 

Related Article

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.