Hello, Dmitry,
Note that when you make the entire column read only. It is achieved by setting the column's
ReadOnly property to true. However, if you cancel the
CellBeginEdit event to indicate the cell is read only, you can create a custom
RadGridView and override the
ProcessDialogKey method to handle the Tab key and to override the
OnMouseDown method to handle the mouse input. Here is demonstrated a sample approach how to skip making the read only cell current and moving to the next cell when pressing Tab:
public
class
CustomGrid : RadGridView
{
protected
override
void
OnMouseDown(MouseEventArgs e)
{
GridCellElement cellUnderMouse =
this
.GridViewElement.ElementTree.GetElementAtPoint(e.Location)
as
GridCellElement;
if
(cellUnderMouse !=
null
&& !IsEditingAllowed(cellUnderMouse.RowInfo.Cells[cellUnderMouse.ColumnInfo.Name]))
{
return
;
}
base
.OnMouseDown(e);
}
protected
override
bool
ProcessDialogKey(Keys keyData)
{
if
(
this
.CurrentRow !=
null
)
{
int
rowIndex =
this
.CurrentRow.Index;
int
columnIndex =
this
.CurrentColumn.Index;
GridViewCellInfo cellInfo;
if
(columnIndex <
this
.Columns.Count - 1)
{
columnIndex++;
}
else
{
columnIndex = 0;
if
(rowIndex <
this
.Rows.Count - 1)
{
rowIndex++;
}
else
{
rowIndex = 0;
}
}
cellInfo =
this
.Rows[rowIndex].Cells[columnIndex];
if
(keyData == Keys.Tab)
{
while
(!IsEditingAllowed(cellInfo.RowInfo.Cells[cellInfo.ColumnInfo.Name]))
{
if
(columnIndex <
this
.Columns.Count - 1)
{
columnIndex++;
}
else
{
columnIndex = 0;
if
(rowIndex <
this
.Rows.Count - 1)
{
rowIndex++;
}
else
{
rowIndex = 0;
}
}
cellInfo =
this
.Rows[rowIndex].Cells[columnIndex];
}
this
.CurrentRow = cellInfo.RowInfo;
this
.CurrentColumn = cellInfo.ColumnInfo;
return
true
;
}
}
return
base
.ProcessDialogKey(keyData);
}
private
bool
IsEditingAllowed(GridViewCellInfo cell)
{
if
(cell.ColumnInfo.Name ==
"ProductName"
)
{
return
false
;
}
return
true
;
}
}
Note that this is just a sample approach and it may not cover all possible cases. Feel free to modify it in a way which suits your requirement best.
I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Progress Telerik