Hi!
I use 2010.3.10.1109.
I have grid with unbound mode and I want use custom sorting. So I set
this.radGridView1.MasterTemplate.EnableCustomSorting = true;and I hooked event CustomSorting.
The problem is that in event args property Column is set as deprecated and is always null. CellValue1 and CellValue2 are also deprecated and have null values. I cannot use radGridView1.CurrentColumn because clicking on column header doesn`t change current column.
So I have problem because I don`t know which column has been clicked by the user.
How to solve this problem?
This is my source code:
namespace GridViewUnboundMode { public partial class Form1 : Form { public Form1() { InitializeComponent(); BuildGrid(); } private void BuildGrid() { for (int index = 0; index < 5; index++) { GridViewDataColumn newColumn = new GridViewTextBoxColumn(); newColumn.HeaderText = "Col" + (radGridView1.Columns.Count + 1).ToString(); newColumn.Name = newColumn.HeaderText; radGridView1.Columns.Add(newColumn); newColumn.AllowSort = true; } for(int index = 0; index < 10; index++) { GridViewRowInfo rowInfo = this.radGridView1.Rows.AddNew(); int columnIndex = 0; int rowIndex = rowInfo.Index; foreach (GridViewCellInfo cellInfo in rowInfo.Cells) { cellInfo.Value = string.Format("{0}-{1}", columnIndex, rowIndex); columnIndex++; } } } private void radGridView1_CustomSorting(object sender, GridViewCustomSortingEventArgs e) { if ((e.Row1 != null) && (e.Row2 == null)) { e.SortResult = 1; } else if ((e.Row1 == null) && (e.Row2 != null)) { e.SortResult = -1; } if ((e.Row1 != null) && (e.Row2 != null)) { //radGridView1.CurrentColumn doesn`t help becasue clicking in column header doesn`t change current column if ((radGridView1.CurrentColumn != null) && (radGridView1.CurrentColumn.Index >= 0)) { e.SortResult = e.Row1.Cells[radGridView1.CurrentColumn.Index].Value.ToString().CompareTo(e.Row2.Cells[radGridView1.CurrentColumn.Index].Value.ToString()); } } } } }
I don`t know also why Handled property (from event args) has value true when my handler is executed. I think at the beginning it should have value false and I should set this on true if I want handle sorting.
Regards Regards Regards