none
datagridview column subheading RRS feed

  • Question

  • i need to two column headings in datagridview first for "mass" and second for its unit kilogram "kg"..please advice me how to do

    thanks in advance......


    guru data

    Monday, July 29, 2013 9:59 PM

Answers

All replies

  • Hello,

    Welcome to MSDN forum.

    From your description, i think you can try to do like this:

    //Create a product table
    DataTable product=new Datatable();
    //Add two columns: mass and kg
    DataColumn newDC;
    newDC = new DataColumn("mass", System.Type.GetType("System.String"));
    product.Columns.Add(newDC);
    newDC = new DataColumn("Kg", System.Type.GetType("System.int"));
    product.Columns.Add(newDC);
    //Add a row                     
     DataRow newDR = scoreDataTable.NewRow();
     newDR = scoreDataTable.NewRow();
     newDR["mass"] = "high";
     newDR["kg"] = 50;
     product.Rows.Add(newDR);
    dataGridView1.DataSource = product;
                       
    Hopes these help,if you have any question,please feel free to contact me.
    Best Regards,

    Lilia Gong
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, July 30, 2013 2:36 AM
    Moderator
  • no sir some misunderstanding my question is how to give two headings for one column

    guru data

    Tuesday, July 30, 2013 3:06 PM
  • Hello,

    Thanks for your reply.

    According to your description, I think you can refer this article:

    http://www.cnblogs.com/neuhawk/archive/2006/09/28/517507.html

    Hope this help, have a nice day.

    Best Regards,


    Lilia Gong
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Albertostin Friday, August 2, 2013 9:50 PM
    Wednesday, July 31, 2013 4:00 PM
    Moderator