Hi Abdul,
This can be achieved by using custom row behavior which allows you to handle the enter key. You can use the Tag property to store the tab indexes. Here is a sample implementation:
public
partial
class
RadForm1 : Telerik.WinControls.UI.RadForm
{
public
RadForm1()
{
InitializeComponent();
radGridView1.DataSource = GetTable();
BaseGridBehavior gridBehavior = radGridView1.GridBehavior
as
BaseGridBehavior;
gridBehavior.UnregisterBehavior(
typeof
(GridViewDataRowInfo));
gridBehavior.RegisterBehavior(
typeof
(GridViewDataRowInfo),
new
CustomGridDataRowBehavior());
}
protected
override
void
OnLoad(EventArgs e)
{
base
.OnLoad(e);
int
count = 100;
foreach
(var row
in
radGridView1.Rows)
{
foreach
(GridViewCellInfo cell
in
row.Cells)
{
cell.Tag = count--;
}
}
}
static
DataTable GetTable()
{
DataTable table =
new
DataTable();
table.Columns.Add(
"Dosage"
,
typeof
(
int
));
table.Columns.Add(
"Drug"
,
typeof
(
string
));
table.Columns.Add(
"Name"
,
typeof
(
string
));
table.Columns.Add(
"Date"
,
typeof
(DateTime));
table.Rows.Add(25,
"Indocin"
,
"David"
, DateTime.Now);
table.Rows.Add(50,
"Enebrel"
,
"Sam"
, DateTime.Now);
table.Rows.Add(10,
"Hydralazine"
,
"Christoff"
, DateTime.Now);
table.Rows.Add(21,
"Combivent"
,
"Janet"
, DateTime.Now);
table.Rows.Add(100,
"Dilantin"
,
"Melanie"
, DateTime.Now);
return
table;
}
}
public
class
CustomGridDataRowBehavior : GridDataRowBehavior
{
protected
override
bool
ProcessEnterKey(KeyEventArgs keys)
{
int
currentIndex = (
int
)
this
.GridControl.CurrentRow.Cells[
this
.GridControl.CurrentColumn.Name].Tag;
foreach
(var row
in
GridControl.Rows)
{
foreach
(GridViewCellInfo cell
in
row.Cells)
{
if
((
int
)cell.Tag == currentIndex + 1)
{
this
.GridControl.CurrentRow = row;
this
.GridControl.CurrentColumn = cell.ColumnInfo;
break
;
}
}
}
return
true
;
}
}
I hope this will be useful.
Regards,
Dimitar
Progress Telerik