Hi,
I am new to datagridview. I want custom sorting on one column of datagridview. For that i have written program. Everything is fine but SortCompare Event is not firing.
Firstly i created one Datagridview in Windows Application and then populated that one. Here is the code:
using
namespace
{
InitializeComponent();
dt =
}
dt.Columns.Add(
row1[
dt.Rows.Add(row1);
row2[
dt.Rows.Add(row2);
row3[
dt.Rows.Add(row3);
row4[
dt.Rows.Add(row4);
dataGridView1.DataSource = dt;
dataGridView1.VirtualMode =
dataGridView1.Columns[
e.SortResult = System.String.Compare(
e.CellValue1.ToString(), e.CellValue2.ToString()); // If the cells are equal, sort based on the column.
if (e.SortResult == 0 && e.Column.Name != "DateofJoining")
dataGridView1.Rows[e.RowIndex1].Cells["DateofJoining"].Value.ToString(),
dataGridView1.Rows[e.RowIndex2].Cells["DateofJoining"].Value.ToString());
e.Handled = true;
I have made virtual mode as false and sort mode as programmatic.
Thanx in advance........
if u want to share some another technique for the same...then urs welcome.......