How add column to datagrid view between particular columns?
here i means ,my colum name is Class, i have a datagrid view with column names that
StudName StudID StudAdd
i want to add my column class add between StudID and StudAdd
my expected output is
StudName StudID Class StudAdd
Loading
VulpesPosted Jun 11, 2011, 8:42 AM
So, to insert a column immediately after it, you'll need a line such as this:
dataGridView1.Columns.Insert(2, ClassColumn);
where ClassColumn is your DataGridViewColumn object.
I'm not absolutely sure but I think you'll also have to set the DisplayIndex for this column to 2 as well, otherwise it will be displayed after the other columns by default.
Vishal GilbilePosted Jun 11, 2011, 7:59 AM
hi you can make use of the following code.
this
.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {this.StudentId,this.Class,this.StudentName});