This is a migrated thread and some comments may be shown as answers.

add column groups and ungroup to datagridview

4 Answers 244 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Maryam
Top achievements
Rank 1
Maryam asked on 23 Feb 2014, 09:28 AM
Hi all,In my winForm program, I made some GridView columns programmatically. and after adding them to GridView
I tried to make just some headers in a group view style. the problem  is when I apply this view changes, the gridview don't load 
other columns which haven't been grouped.
the code I used to change the view is  in below and notice I wrote them after adding columns to DGV. Thanks in advance
...
//adding 8 columns to DGV programmatically
....
//make just 6 column in a group format
ColumnGroupsViewDefinition view = new ColumnGroupsViewDefinition();
            dataGridView1.ViewDefinition = view;
            view.ColumnGroups.Add(new GridViewColumnGroup("morning));
            view.ColumnGroups[1].Rows.Add(new GridViewColumnGroupRow());
            view.ColumnGroups[1].Rows[0].Columns.Add(this.dataGridView1.Columns["MrnngEnt"]);
            view.ColumnGroups[1].Rows[0].Columns.Add(this.dataGridView1.Columns["MrnngExit"]);
            view.ColumnGroups.Add(new GridViewColumnGroup("evnng"));
            view.ColumnGroups[2].Rows.Add(new GridViewColumnGroupRow());
            view.ColumnGroups[2].Rows[0].Columns.Add(this.dataGridView1.Columns["EvnngEnt"]);
            view.ColumnGroups[2].Rows[0].Columns.Add(this.dataGridView1.Columns["EvnngExit"]);
            view.ColumnGroups.Add(new GridViewColumnGroup("over"));
            view.ColumnGroups[3].Rows.Add(new GridViewColumnGroupRow());
            view.ColumnGroups[3].Rows[0].Columns.Add(this.dataGridView1.Columns["OvrEnt"]);
            view.ColumnGroups[3].Rows[0].Columns.Add(this.dataGridView1.Columns["OvrExit"]);       
        }

4 Answers, 1 is accepted

Sort by
0
Maryam
Top achievements
Rank 1
answered on 25 Feb 2014, 06:44 AM
Up
0
Accepted
Dimitar
Telerik team
answered on 26 Feb 2014, 03:14 PM
Hi Mary,

Thank you for writing.

All columns must be added to the ColumnGroupsViewDefinition view in order to be visible. For example you can add all eight columns to the view like this:
public Form1()
{
    InitializeComponent();
    radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
    for (int i = 1; i < 9; i++)
    {
        radGridView1.Columns.Add("Column " + i);
    }
    new Telerik.WinControls.RadControlSpy.RadControlSpyForm().Show();
    ColumnGroupsViewDefinition view = new ColumnGroupsViewDefinition();
     
    view.ColumnGroups.Add(new GridViewColumnGroup("morning"));
    view.ColumnGroups[0].Rows.Add(new GridViewColumnGroupRow());
    view.ColumnGroups[0].Rows[0].Columns.Add(this.radGridView1.Columns["Column 1"]);
    view.ColumnGroups[0].Rows[0].Columns.Add(this.radGridView1.Columns["Column 2"]);
 
    view.ColumnGroups.Add(new GridViewColumnGroup("evening"));
    view.ColumnGroups[1].Rows.Add(new GridViewColumnGroupRow());
    view.ColumnGroups[1].Rows[0].Columns.Add(this.radGridView1.Columns["Column 3"]);
    view.ColumnGroups[1].Rows[0].Columns.Add(this.radGridView1.Columns["Column 4"]);
 
    view.ColumnGroups.Add(new GridViewColumnGroup("over"));
    view.ColumnGroups[2].Rows.Add(new GridViewColumnGroupRow());
    view.ColumnGroups[2].Rows[0].Columns.Add(this.radGridView1.Columns["Column 5"]);
    view.ColumnGroups[2].Rows[0].Columns.Add(this.radGridView1.Columns["Column 6"]);
 
    view.ColumnGroups.Add(new GridViewColumnGroup());
    view.ColumnGroups[3].Rows.Add(new GridViewColumnGroupRow());
    view.ColumnGroups[3].Rows[0].Columns.Add(this.radGridView1.Columns["Column 7"]);
    view.ColumnGroups[3].Rows[0].Columns.Add(this.radGridView1.Columns["Column 8"]);
 
    radGridView1.ViewDefinition = view;
}

Also please note that if you need row span and col span functionality you can use the HTML View.

I hope this information helps. Should you have any other questions, I will be glad to assist you.

Regards,
Dimitar
Telerik
0
Maryam
Top achievements
Rank 1
answered on 02 Mar 2014, 04:18 AM
Thanks for your help.It works. I also add this line " view.ColumnGroups[2].ShowHeader = false;" to hide the header of UnGrouped columns in ColumnGroups[2].
0
Tofan
Top achievements
Rank 1
answered on 20 Sep 2018, 10:52 AM

Is there any maximum number of GridViewColumnGroup that you can assign to a RadGrid? I can add 23 groups (each contain subgroup) but when  I add the 24 group I get :

"An unhandled exception of type 'System.NullReferenceException' occurred in Telerik.WinControls.GridView.dll

Additional information: Object reference not set to an instance of an object."

I use the DLL from 2014. Any advice is helpful. I thank you much for your help and time.

My function is 

[QOUTE][ColumnGroupsViewDefinition view = new ColumnGroupsViewDefinition();

            // Group Header

            view.ColumnGroups.Add(new GridViewColumnGroup(""));
            view.ColumnGroups[0].Rows.Add(new GridViewColumnGroupRow());
            view.ColumnGroups[0].Rows[0].Columns.Add(dg_validare_antecalcul.Columns["pk_pr_cip"]);
            view.ColumnGroups[0].Rows[0].Columns.Add(dg_validare_antecalcul.Columns["Bifa"]);
            view.ColumnGroups[0].Rows[0].Columns.Add(dg_validare_antecalcul.Columns["Cip"]);
            view.ColumnGroups[0].Rows[0].Columns.Add(dg_validare_antecalcul.Columns["Program"]);
            view.ColumnGroups[0].Rows[0].Columns.Add(dg_validare_antecalcul.Columns["Reper"]);
            view.ColumnGroups[0].Rows[0].Columns.Add(dg_validare_antecalcul.Columns["Denumire Reper"]);
            view.ColumnGroups[0].ShowHeader = false;

            // CSTA

            GridViewColumnGroup oGroup = new GridViewColumnGroup();
            oGroup.Text = "CSTA";

            GridViewColumnGroup oSubGroup = new GridViewColumnGroup();
            oSubGroup.Text = "Pret de vanzare unitar";
            oSubGroup.Rows.Add(new GridViewColumnGroupRow());
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTA_unitar"]);
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTA_cip"]);

            dg_validare_antecalcul.Columns["CSTA_unitar"].HeaderText = "UNITAR";
            dg_validare_antecalcul.Columns["CSTA_cip"].HeaderText = "CIP";

            oGroup.Groups.Add(oSubGroup);
            view.ColumnGroups.Add(oGroup);

            // cost complet

            oGroup = new GridViewColumnGroup();
            oGroup.Text = "";

            oSubGroup = new GridViewColumnGroup();
            oSubGroup.Text = "COST COMPLET";
            oSubGroup.Rows.Add(new GridViewColumnGroupRow());
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["cost_complet_unitar"]);
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["cost_complet_cip"]);

            dg_validare_antecalcul.Columns["cost_complet_unitar"].HeaderText = "UNITAR";
            dg_validare_antecalcul.Columns["cost_complet_cip"].HeaderText = "CIP";

            oGroup.Groups.Add(oSubGroup);
            oGroup.ShowHeader = false;
            view.ColumnGroups.Add(oGroup);

            // CSTB

            oGroup = new GridViewColumnGroup();
            oGroup.Text = "CSTB";

            oSubGroup = new GridViewColumnGroup();
            oSubGroup.Text = "Profit";
            oSubGroup.Rows.Add(new GridViewColumnGroupRow());
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTB_unitar"]);
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTB_cip"]);

            dg_validare_antecalcul.Columns["CSTB_unitar"].HeaderText = "UNITAR";
            dg_validare_antecalcul.Columns["CSTB_cip"].HeaderText = "CIP";

            oGroup.Groups.Add(oSubGroup);
            view.ColumnGroups.Add(oGroup);

            // CSTC

            oGroup = new GridViewColumnGroup();
            oGroup.Text = "CSTC";

            oSubGroup = new GridViewColumnGroup();
            oSubGroup.Text = "Ch. generale de administratie";
            oSubGroup.Rows.Add(new GridViewColumnGroupRow());
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTC_unitar"]);
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTC_cip"]);

            dg_validare_antecalcul.Columns["CSTC_unitar"].HeaderText = "UNITAR";
            dg_validare_antecalcul.Columns["CSTC_cip"].HeaderText = "CIP";

            oGroup.Groups.Add(oSubGroup);
            view.ColumnGroups.Add(oGroup);

            // CSTD

            oGroup = new GridViewColumnGroup();
            oGroup.Text = "CSTD";

            oSubGroup = new GridViewColumnGroup();
            oSubGroup.Text = "Costuri desfacere";
            oSubGroup.Rows.Add(new GridViewColumnGroupRow());
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTD_unitar"]);
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTD_cip"]);

            dg_validare_antecalcul.Columns["CSTD_unitar"].HeaderText = "UNITAR";
            dg_validare_antecalcul.Columns["CSTD_cip"].HeaderText = "CIP";

            oGroup.Groups.Add(oSubGroup);
            view.ColumnGroups.Add(oGroup);

            // CSTE

            oGroup = new GridViewColumnGroup();
            oGroup.Text = "CSTE";

            oSubGroup = new GridViewColumnGroup();
            oSubGroup.Text = "Cost de productie antecalculat-total";
            oSubGroup.Rows.Add(new GridViewColumnGroupRow());
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTE_unitar"]);
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTE_cip"]);

            dg_validare_antecalcul.Columns["CSTE_unitar"].HeaderText = "UNITAR";
            dg_validare_antecalcul.Columns["CSTE_cip"].HeaderText = "CIP";

            oGroup.Groups.Add(oSubGroup);
            view.ColumnGroups.Add(oGroup);

            // CSTF

            oGroup = new GridViewColumnGroup();
            oGroup.Text = "CSTF";

            oSubGroup = new GridViewColumnGroup();
            oSubGroup.Text = "Ch. indirecte af. Diviziei strategice";
            oSubGroup.Rows.Add(new GridViewColumnGroupRow());
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTF_unitar"]);
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTF_cip"]);

            dg_validare_antecalcul.Columns["CSTF_unitar"].HeaderText = "UNITAR";
            dg_validare_antecalcul.Columns["CSTF_cip"].HeaderText = "CIP";

            oGroup.Groups.Add(oSubGroup);
            view.ColumnGroups.Add(oGroup);

            // CSTG

            oGroup = new GridViewColumnGroup();
            oGroup.Text = "CSTG";

            oSubGroup = new GridViewColumnGroup();
            oSubGroup.Text = "Ch. indirecte af. Diviziei conducatoare";
            oSubGroup.Rows.Add(new GridViewColumnGroupRow());
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTG_unitar"]);
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTG_cip"]);

            dg_validare_antecalcul.Columns["CSTG_unitar"].HeaderText = "UNITAR";
            dg_validare_antecalcul.Columns["CSTG_cip"].HeaderText = "CIP";

            oGroup.Groups.Add(oSubGroup);
            view.ColumnGroups.Add(oGroup);

            // CSTH

            oGroup = new GridViewColumnGroup();
            oGroup.Text = "CSTH";

            oSubGroup = new GridViewColumnGroup();
            oSubGroup.Text = "Cost de productie antecalculat-propriu";
            oSubGroup.Rows.Add(new GridViewColumnGroupRow());
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTH_unitar"]);
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTH_cip"]);

            dg_validare_antecalcul.Columns["CSTH_unitar"].HeaderText = "UNITAR";
            dg_validare_antecalcul.Columns["CSTH_cip"].HeaderText = "CIP";

            oGroup.Groups.Add(oSubGroup);
            view.ColumnGroups.Add(oGroup);

            // CSTI

            oGroup = new GridViewColumnGroup();
            oGroup.Text = "CSTI";

            oSubGroup = new GridViewColumnGroup();
            oSubGroup.Text = "Ch. indirecte de sectie";
            oSubGroup.Rows.Add(new GridViewColumnGroupRow());
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTI_unitar"]);
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTI_cip"]);

            dg_validare_antecalcul.Columns["CSTI_unitar"].HeaderText = "UNITAR";
            dg_validare_antecalcul.Columns["CSTI_cip"].HeaderText = "CIP";

            oGroup.Groups.Add(oSubGroup);
            view.ColumnGroups.Add(oGroup);

            // CSTJ

            oGroup = new GridViewColumnGroup();
            oGroup.Text = "CSTJ";

            oSubGroup = new GridViewColumnGroup();
            oSubGroup.Text = "Materiale directe";
            oSubGroup.Rows.Add(new GridViewColumnGroupRow());
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTJ_unitar"]);
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTJ_cip"]);

            dg_validare_antecalcul.Columns["CSTJ_unitar"].HeaderText = "UNITAR";
            dg_validare_antecalcul.Columns["CSTJ_cip"].HeaderText = "CIP";

            oGroup.Groups.Add(oSubGroup);
            view.ColumnGroups.Add(oGroup);

            // CSTK

            oGroup = new GridViewColumnGroup();
            oGroup.Text = "CSTK";

            oSubGroup = new GridViewColumnGroup();
            oSubGroup.Text = "Nevoi proprii directe";
            oSubGroup.Rows.Add(new GridViewColumnGroupRow());
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTK_unitar"]);
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTK_cip"]);

            dg_validare_antecalcul.Columns["CSTK_unitar"].HeaderText = "UNITAR";
            dg_validare_antecalcul.Columns["CSTK_cip"].HeaderText = "CIP";

            oGroup.Groups.Add(oSubGroup);
            view.ColumnGroups.Add(oGroup);

            // CSTL

            oGroup = new GridViewColumnGroup();
            oGroup.Text = "CSTL";

            oSubGroup = new GridViewColumnGroup();
            oSubGroup.Text = "Chelt. cu scule";
            oSubGroup.Rows.Add(new GridViewColumnGroupRow());
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTL_unitar"]);
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTL_cip"]);

            dg_validare_antecalcul.Columns["CSTL_unitar"].HeaderText = "UNITAR";
            dg_validare_antecalcul.Columns["CSTL_cip"].HeaderText = "CIP";

            oGroup.Groups.Add(oSubGroup);
            view.ColumnGroups.Add(oGroup);

            // CSTM

            oGroup = new GridViewColumnGroup();
            oGroup.Text = "CSTM";

            oSubGroup = new GridViewColumnGroup();
            oSubGroup.Text = "Ch. transp-aprov.";
            oSubGroup.Rows.Add(new GridViewColumnGroupRow());
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTM_unitar"]);
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTM_cip"]);

            dg_validare_antecalcul.Columns["CSTM_unitar"].HeaderText = "UNITAR";
            dg_validare_antecalcul.Columns["CSTM_cip"].HeaderText = "CIP";

            oGroup.Groups.Add(oSubGroup);
            view.ColumnGroups.Add(oGroup);

            // CSTN

            oGroup = new GridViewColumnGroup();
            oGroup.Text = "CSTN";

            oSubGroup = new GridViewColumnGroup();
            oSubGroup.Text = "Manopera directa";
            oSubGroup.Rows.Add(new GridViewColumnGroupRow());
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTN_unitar"]);
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTN_cip"]);

            dg_validare_antecalcul.Columns["CSTN_unitar"].HeaderText = "UNITAR";
            dg_validare_antecalcul.Columns["CSTN_cip"].HeaderText = "CIP";

            oGroup.Groups.Add(oSubGroup);
            view.ColumnGroups.Add(oGroup);

            // CSTO

            oGroup = new GridViewColumnGroup();
            oGroup.Text = "CSTO";

            oSubGroup = new GridViewColumnGroup();
            oSubGroup.Text = "Indexare manop. directa ramasa";
            oSubGroup.Rows.Add(new GridViewColumnGroupRow());
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTO_unitar"]);
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTO_cip"]);

            dg_validare_antecalcul.Columns["CSTO_unitar"].HeaderText = "UNITAR";
            dg_validare_antecalcul.Columns["CSTO_cip"].HeaderText = "CIP";

            oGroup.Groups.Add(oSubGroup);
            view.ColumnGroups.Add(oGroup);

            // CSTP

            oGroup = new GridViewColumnGroup();
            oGroup.Text = "CSTP";

            oSubGroup = new GridViewColumnGroup();
            oSubGroup.Text = "Ch. salarii colaboratori";
            oSubGroup.Rows.Add(new GridViewColumnGroupRow());
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTP_unitar"]);
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTP_cip"]);

            dg_validare_antecalcul.Columns["CSTP_unitar"].HeaderText = "UNITAR";
            dg_validare_antecalcul.Columns["CSTP_cip"].HeaderText = "CIP";

            oGroup.Groups.Add(oSubGroup);
            view.ColumnGroups.Add(oGroup);

            // CSTQ

            oGroup = new GridViewColumnGroup();
            oGroup.Text = "CSTQ";

            oSubGroup = new GridViewColumnGroup();
            oSubGroup.Text = "C.A.S. si alte fonduri af.(manop. directe+sporuri)";
            oSubGroup.Rows.Add(new GridViewColumnGroupRow());
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTQ_unitar"]);
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTQ_cip"]);

            dg_validare_antecalcul.Columns["CSTQ_unitar"].HeaderText = "UNITAR";
            dg_validare_antecalcul.Columns["CSTQ_cip"].HeaderText = "CIP";

            oGroup.Groups.Add(oSubGroup);
            view.ColumnGroups.Add(oGroup);

            // CSTR

            oGroup = new GridViewColumnGroup();
            oGroup.Text = "CSTR";

            oSubGroup = new GridViewColumnGroup();
            oSubGroup.Text = "S.D.V. directe";
            oSubGroup.Rows.Add(new GridViewColumnGroupRow());
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTR_unitar"]);
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTR_cip"]);

            dg_validare_antecalcul.Columns["CSTR_unitar"].HeaderText = "UNITAR";
            dg_validare_antecalcul.Columns["CSTR_cip"].HeaderText = "CIP";

            oGroup.Groups.Add(oSubGroup);
            view.ColumnGroups.Add(oGroup);

            // CSTS

            oGroup = new GridViewColumnGroup();
            oGroup.Text = "CSTS";

            oSubGroup = new GridViewColumnGroup();
            oSubGroup.Text = "Alte costuri directe";
            oSubGroup.Rows.Add(new GridViewColumnGroupRow());
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTS_unitar"]);
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTS_cip"]);

            dg_validare_antecalcul.Columns["CSTS_unitar"].HeaderText = "UNITAR";
            dg_validare_antecalcul.Columns["CSTS_cip"].HeaderText = "CIP";

            oGroup.Groups.Add(oSubGroup);
            view.ColumnGroups.Add(oGroup);

            // CSTT

            oGroup = new GridViewColumnGroup();
            oGroup.Text = "CSTT";

            oSubGroup = new GridViewColumnGroup();
            oSubGroup.Text = "Colaborari directe";
            oSubGroup.Rows.Add(new GridViewColumnGroupRow());
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTT_unitar"]);
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTT_cip"]);

            dg_validare_antecalcul.Columns["CSTT_unitar"].HeaderText = "UNITAR";
            dg_validare_antecalcul.Columns["CSTT_cip"].HeaderText = "CIP";

            oGroup.Groups.Add(oSubGroup);
            view.ColumnGroups.Add(oGroup);

            // CSTU
            //GridViewColumnGroup oGroup1 = new GridViewColumnGroup();
            //oGroup1.Text = "";

            GridViewColumnGroup oGroupU = new GridViewColumnGroup();
            oGroupU.Text = "CSTU";

            oSubGroup = new GridViewColumnGroup();
            oSubGroup.Text = "Utilitati directe";
            oSubGroup.Rows.Add(new GridViewColumnGroupRow());
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTU_unitar"]);
            oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTU_cip"]);

            dg_validare_antecalcul.Columns["CSTU_unitar"].HeaderText = "UNITAR";
            dg_validare_antecalcul.Columns["CSTU_cip"].HeaderText = "CIP";

            oGroupU.Groups.Add(oSubGroup);
            //oGroup1.Groups.Add(oGroupU);
            view.ColumnGroups.Add(oGroupU);

            // CSTV

            GridViewColumnGroup oGroupV = new GridViewColumnGroup();
            oGroupV.Text = "CSTV";

            GridViewColumnGroup oSubGroupV = new GridViewColumnGroup();
            oSubGroupV.Text = "Corectii";
            oSubGroupV.Rows.Add(new GridViewColumnGroupRow());
            oSubGroupV.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTV_unitar"]);
            oSubGroupV.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTV_cip"]);

            dg_validare_antecalcul.Columns["CSTV_unitar"].HeaderText = "UNITAR";
            dg_validare_antecalcul.Columns["CSTV_cip"].HeaderText = "CIP";

            oGroupV.Groups.Add(oSubGroupV);
            //oGroup1.Groups.Add(oGroupV);
            //oGroup1.ShowHeader = false;
            //view.ColumnGroups.Add(oGroup1);
            view.ColumnGroups.Add(oGroupV);

            dg_validare_antecalcul.ViewDefinition = view;/QUOTE]

Comment any of the of the grouping and fill grid works. With all the groups the fill grid gives error at the last line. 

Tags
GridView
Asked by
Maryam
Top achievements
Rank 1
Answers by
Maryam
Top achievements
Rank 1
Dimitar
Telerik team
Tofan
Top achievements
Rank 1
Share this question
or