0

Hi,
I have a datagridview with many columns.I want to give this GridView Columns proper order according to my requirement.
Like example.
I have three columns
1.RegNo.
2.Name.
3.Address.

I want that the Name should be the first Column,RegNo second and Adress Third.
My application is in Silverlight Coded in C#.Net.
Please guide.
Thanks in advance

3
Contributors
6
Replies
7
Views
6 Years
Discussion Span
Last Post by Ehtesham Siddiq
0

Based on the Select query you wrote the columns will come .
for example write in this way : select Regno,Name,Adress,Pincode from temptable
this may gives you correct result

1

You can set tje order of the columns like:

dataGridView1.Columns["Name"].DisplayIndex = 0;
    dataGridView1.Columns["RegNo"].DisplayIndex = 1;
    dataGridView1.Columns["Adress"].DisplayIndex = 2;
Votes + Comments
++
0

Hi Bonca,
thanks fr ur rply...
but when i use the above code and give name to columns .Columns["RegNo"].DisplayIndex = 0;
its showing error as this.[int] has some invalid argument rather when i use
.Columns[0].DisplayIndex = 0; ,this means it only takes int type...
please suggest...

0

Did you sort all the columns? if you change one, you have to re-order all the others. So that two columns wont have same columnIndex maybe.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.