Windows Develop Bookmark and Share   
 index > Windows Forms General > How to stop ordering of rows in datagridview by clicking on column of datagridview?
 

How to stop ordering of rows in datagridview by clicking on column of datagridview?

I need to stop the ordering of rows by clicking on the column header of datagridview.

Actually I need to enter the data into the particular rows and columns of datagridview. So, I can't make the datagridview disabled. If i change the order of the rows then the format i designed of datagridview got changed which i shouldn't want.

I do not find any property of datagridview to stop the ordereing.

Please help if any one have solution for that problem.

Sandeep Soni  Saturday, August 18, 2007 5:43 AM

The property you're looking for is on the Column's themselves I believe. You should be able to set Sorting to Non Sortable on each individual column as you desire.
Dennis Stone  Saturday, August 18, 2007 6:20 AM

I believe this should help to stop the reordering. Use this before entering the data into the datagridview.

Code Snippet

foreach (DataGridViewColumn var in this.dataGridView1.Columns)

{

var.SortMode = DataGridViewColumnSortMode.NotSortable;

}

Yun Feng  Saturday, August 18, 2007 10:48 AM

That solution is used to disabling the sorting of rows on clicking the header of every columns of DataGridView.

Now I search that I can also able to disable the sorting of datagridviewcolumn by column wise.

like : DataGridView1.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;

Thank You Sir for that solution.

Sandeep Soni  Monday, August 20, 2007 4:04 AM

The property you're looking for is on the Column's themselves I believe. You should be able to set Sorting to Non Sortable on each individual column as you desire.
Dennis Stone  Saturday, August 18, 2007 6:20 AM

I believe this should help to stop the reordering. Use this before entering the data into the datagridview.

Code Snippet

foreach (DataGridViewColumn var in this.dataGridView1.Columns)

{

var.SortMode = DataGridViewColumnSortMode.NotSortable;

}

Yun Feng  Saturday, August 18, 2007 10:48 AM

That solution is used to disabling the sorting of rows on clicking the header of every columns of DataGridView.

Now I search that I can also able to disable the sorting of datagridviewcolumn by column wise.

like : DataGridView1.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;

Thank You Sir for that solution.

Sandeep Soni  Monday, August 20, 2007 4:04 AM

You can use google to search for other answers

Custom Search

More Threads

• Paragraphs in richtextbox
• get IWin32Window of form executed some code without having the instance of the form
• How to use javascript in vb.net window application
• WebBrowser Control Fails to refresh
• How to have one instance of the form? VB.net or VS 2005(VB)
• Changing BKColor of windowclass
• Problems with RichtTextBox
• OnMouseWheel on inactive control
• in a form i need to all the featurs of ms outlook
• Win32Exception .... Please help