Hi Vulupes and Ishan
in DatagridView (not bound to DB), would like to sort rows based on the priority of the row.
I have one method that change the fontcolor of row based on the priority
//Part of method///
if((row.cells[0].value).toString()=="High")
{
row.DefaultCellStyle.ForeColor = System.Drawing.Color.Red;
}
but I want all the rows that have red fontcolor to be displayed on the top of the list. In other words, if I set or change the importance of row to "high" then the row will be displayed automatically to the top of the list.
I have one method for sorting, but it doesn't work as I want:
private void SortRows()
{
dgv.Sort(dgv.Columns[0], ListSortDirection.Descending);
}
Loading
Eline SamiPosted May 5, 2015, 7:05 AM
I couldn't implement the same
Akhil GargPosted May 4, 2015, 6:46 AM
Create one property like int intPriority and based on you priority assign number like
High=1, Medium=2,Low=3 and set intPriority as your sortmemberpath.
Abrar Ahmad AnsariPosted May 4, 2015, 4:41 AM
select * from tableName
where columnname="High"
union all
select * from columnname<>"High"
column values before binding the grid.
Abhay ShankerPosted May 4, 2015, 3:35 AM
http://www.c-sharpcorner.com/uploadfile/prathore/sorting-with-datagridview-using-C-Sharp/
http://csharp.net-informations.com/datagridview/csharp-datagridview-filter.htm