Hi
I have a radGridView with groups that has two read only columns and one editable column. Using the tab key within a group works fine - it tabs to the only editable cell in the next row and I can immediately start typing in that cell. However when I get to the last row in the group and hit the tab key, it tabs to the group header row of the next group. I hit the tab key again and it tabs to the first read only cell in the first row for the group. The next tab goes to the second read only cell and the next tab goes to the first editable cell, but I can't type in that cell without first clicking in it. Is there any way I can get the tab from the last row of a group to the first editable cell of the first row in the next group?
4 Answers, 1 is accepted
Thank you for writing.
RadGridView manages user mouse and keyboard input over its rows by GridRowBehavior. Depending on the row type, RadGridView introduces different behaviors. The following help article is quite useful on this topic and it demonstrates a simple approach how to handle keyboard input and achieve the desired behavior: http://docs.telerik.com/devtools/winforms/gridview/rows/row-behaviors
I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
Telerik by Progress
Hi Dess
That didn't seem to do anything, maybe because I don't actually have a hierarchical grid. I use group descriptors to create the groups, ie
Dim descriptor1 As New GroupDescriptor()
descriptor1.GroupNames.Add("colHeadingID", ListSortDirection.Ascending)
dgv.GroupDescriptors.Add(descriptor1)
Is there any way to make the tab key work as described for this kind of grid?
Hi Dess
That didn't seem to do anything, maybe because I don't have a hierarchical grid. I set the groups up using group descriptors, ie
Dim descriptor1 As New GroupDescriptor()
descriptor1.GroupNames.Add("colHeadingID", ListSortDirection.Ascending)
dgv.GroupDescriptors.Add(descriptor1)
Is there any way to make the tab key work as described for this kind of grid?
Thank you for writing back.
Here is a sample code snippet demonstrating how to handle pressing the Tab key and navigate to the next editable cell no matter if it is in the next group or not:
public
RadForm1()
{
InitializeComponent();
this
.radGridView1.Columns.Add(
"Id"
);
this
.radGridView1.Columns.Add(
"Name"
);
this
.radGridView1.Columns.Add(
"IsActive"
);
for
(
int
i = 0; i < 10; i++)
{
this
.radGridView1.Rows.Add(i,
"Item"
+ i, i % 2 == 0);
}
this
.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
this
.radGridView1.Columns[0].ReadOnly =
true
;
this
.radGridView1.Columns[1].ReadOnly =
true
;
this
.radGridView1.MasterTemplate.ShowGroupedColumns =
true
;
GroupDescriptor descriptor =
new
GroupDescriptor();
descriptor.GroupNames.Add(
"IsActive"
, ListSortDirection.Ascending);
this
.radGridView1.GroupDescriptors.Add(descriptor);
//register the custom row behavior
BaseGridBehavior gridBehavior = radGridView1.GridBehavior
as
BaseGridBehavior;
gridBehavior.UnregisterBehavior(
typeof
(GridViewDataRowInfo));
gridBehavior.RegisterBehavior(
typeof
(GridViewDataRowInfo),
new
CustomGridDataRowBehavior());
this
.radGridView1.PreviewKeyDown += RadGridView1_PreviewKeyDown;
}
private
void
RadGridView1_PreviewKeyDown(
object
sender, PreviewKeyDownEventArgs e)
{
if
(e.KeyData == Keys.Tab &&
this
.radGridView1.CurrentRow
is
GridViewGroupRowInfo)
{
this
.radGridView1.CurrentRow =
this
.radGridView1.CurrentRow.ChildRows.First();
}
}
public
class
CustomGridDataRowBehavior : GridDataRowBehavior
{
protected
override
bool
ProcessTabKey(KeyEventArgs keys)
{
bool
result =
base
.ProcessTabKey(keys);
while
(
this
.GridViewElement.CurrentColumn.ReadOnly)
{
this
.GridViewElement.Navigator.SelectNextColumn();
}
if
(
this
.GridViewElement.CurrentRow
is
GridViewGroupRowInfo)
{
this
.GridViewElement.CurrentRow =
this
.GridViewElement.CurrentRow.ChildRows.First();
}
return
result;
}
}
private
void
RadForm1_Load(
object
sender, EventArgs e)
{
foreach
(GridViewRowInfo row
in
this
.radGridView1.ChildRows)
{
row.IsExpanded =
true
;
}
}
I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Telerik by Progress