DataGridView.ProcessRightKey(Keys) Metoda
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Zpracovává klávesu ŠIPKA VPRAVO.
protected:
bool ProcessRightKey(System::Windows::Forms::Keys keyData);
protected bool ProcessRightKey(System.Windows.Forms.Keys keyData);
member this.ProcessRightKey : System.Windows.Forms.Keys -> bool
Protected Function ProcessRightKey (keyData As Keys) As Boolean
Parametry
Návraty
truepokud byl klíč zpracován; v opačném případě . false
Výjimky
Klávesa ŠIPKA VPRAVO způsobí, že ovládací prvek přejde do režimu úprav, ale EditType vlastnost nové aktuální buňky neuvádí třídu, která je odvozena a Control implementuje IDataGridViewEditingControl.
Tato akce potvrdí hodnotu buňky nebo přejde do režimu úprav, ale chyba ve zdroji dat zabrání akci a buď neexistuje žádná obslužná rutina události DataError , nebo obslužná rutina nastavila ThrowException vlastnost na true.
Příklady
Následující příklad kódu ukazuje, jak změnit chování klávesy ENTER v DataGridView podtřídě přepsáním ProcessDataGridViewKey a ProcessDialogKey metodami. V příkladu má klávesa ENTER stejné chování jako klávesa ŠIPKA VPRAVO, což uživateli usnadňuje úpravu více buněk v jednom řádku dat.
public class CustomDataGridView : DataGridView
{
protected override bool ProcessDialogKey(Keys keyData)
{
// Extract the key code from the key value.
Keys key = (keyData & Keys.KeyCode);
// Handle the ENTER key as if it were a RIGHT ARROW key.
if (key == Keys.Enter)
{
return this.ProcessRightKey(keyData);
}
return base.ProcessDialogKey(keyData);
}
protected override bool ProcessDataGridViewKey(KeyEventArgs e)
{
// Handle the ENTER key as if it were a RIGHT ARROW key.
if (e.KeyCode == Keys.Enter)
{
return this.ProcessRightKey(e.KeyData);
}
return base.ProcessDataGridViewKey(e);
}
}
Public Class CustomDataGridView
Inherits DataGridView
<System.Security.Permissions.UIPermission( _
System.Security.Permissions.SecurityAction.LinkDemand, _
Window:=System.Security.Permissions.UIPermissionWindow.AllWindows)> _
Protected Overrides Function ProcessDialogKey( _
ByVal keyData As Keys) As Boolean
' Extract the key code from the key value.
Dim key As Keys = keyData And Keys.KeyCode
' Handle the ENTER key as if it were a RIGHT ARROW key.
If key = Keys.Enter Then
Return Me.ProcessRightKey(keyData)
End If
Return MyBase.ProcessDialogKey(keyData)
End Function
<System.Security.Permissions.SecurityPermission( _
System.Security.Permissions.SecurityAction.LinkDemand, Flags:= _
System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)> _
Protected Overrides Function ProcessDataGridViewKey( _
ByVal e As System.Windows.Forms.KeyEventArgs) As Boolean
' Handle the ENTER key as if it were a RIGHT ARROW key.
If e.KeyCode = Keys.Enter Then
Return Me.ProcessRightKey(e.KeyData)
End If
Return MyBase.ProcessDataGridViewKey(e)
End Function
End Class