I want to set the current cell after performing a ResetBindings to allow seemless keyboard entry. In my example code below I would like to be able to edit the Name column after tabbing out of the Age column. The row appears highlighted but I must navigate to a different row before I can continue editing
public
class
MyData : IComparable
{
public
int
Age {
get
;
set
; }
public
string
Name {
get
;
set
; }
public
MyData ()
{
}
public
MyData (
string
name,
int
age)
{
Name = name;
Age = age;
}
public
int
CompareTo (
object
obj)
{
var other = obj
as
MyData;
if
(other ==
null
)
return
0;
if
(
this
.Age > other.Age)
return
1;
if
(
this
.Age < other.Age)
return
-1;
return
0;
}
}
private
List<MyData> m_dataSource;
private
BindingSource myDataBindingSource =
new
BindingSource();
public
Form1()
{
InitializeComponent();
this
.radGridView1.MasterTemplate.DataSource = myDataBindingSource;
m_dataSource = PopulateData ();
this
.myDataBindingSource.DataSource = m_dataSource;
radGridView1.CellEndEdit += radGridView1_CellEndEdit;
}
void
radGridView1_CellEndEdit(
object
sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
{
var data =
this
.radGridView1.CurrentRow.DataBoundItem
as
MyData;
m_dataSource.Sort();
myDataBindingSource.ResetBindings(
false
);
if
(data !=
null
)
{
foreach
(var row
in
this
.radGridView1.Rows)
{
if
(row.DataBoundItem == data)
{
row.IsCurrent =
true
;
}
else
{
row.IsCurrent =
false
;
}
}
}
}
private
List<MyData> PopulateData ()
{
List<MyData> dataList =
new
List<MyData> ();
dataList.Add (
new
MyData (
"A"
, 1));
dataList.Add (
new
MyData (
"B"
, 7));
dataList.Add (
new
MyData (
"C"
, 3));
dataList.Add (
new
MyData (
"D"
, 5));
dataList.Add (
new
MyData (
"E"
, 15));
return
dataList;
}