Disable Default Sorting In datagridview
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
Here we re going to see how disable default sorting in datagridview. We can do this by either by code or by design. We will see it in step by step.
Disabling Default Sorting at design
To start right click on datagridview -> select edit columns
add a column -> then in the column properties give sortmode to either
programatic or none or anything you want
Disabling Default Sorting at Program
Another way is in the program write code as below
foreach (DataGridViewColumn col in dataGridView1.Columns)
{
col.SortMode = DataGridViewColumnSortMode.NotSortable;
}
Sorting Datagridview Columns
When giving datasource to datagridview we can sort rows of datagridview
see the example below
DataTable dt = GetTbl();
dt.DefaultView.Sort=dataGridView1.Columns[0].Name+"ASC"; //OR DESC
datagridview1.datasource=dt;
GOR BLESS YOU
MOTHER MARY PRAY FOR US
Ref: ID Card Printing Software