Control.ProcessMnemonic(Char) Metódus
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Mnemonikus karaktert dolgoz fel.
protected:
virtual bool ProcessMnemonic(char charCode);
protected public:
virtual bool ProcessMnemonic(char charCode);
protected virtual bool ProcessMnemonic(char charCode);
protected internal virtual bool ProcessMnemonic(char charCode);
abstract member ProcessMnemonic : char -> bool
override this.ProcessMnemonic : char -> bool
Protected Overridable Function ProcessMnemonic (charCode As Char) As Boolean
Protected Friend Overridable Function ProcessMnemonic (charCode As Char) As Boolean
Paraméterek
- charCode
- Char
A feldolgozandó karakter.
Válaszok
trueha a karaktert a vezérlő mnemonikusként dolgozza fel; egyéb esetben. false
Példák
Az alábbi példakód a gombosztály olyan bővítményét mutatja be, amely felülírja az ProcessMnemonic egyéni viselkedést megjelenítő metódust. A példa a tulajdonságok és CanSelect a IsMnemonic tulajdonságok használatát is bemutatja. A példa futtatásához illessze be az alábbi kódot egy űrlaposztály után ugyanabba a fájlba. Adjon hozzá egy típusgombot MnemonicButton az űrlaphoz.
// This button is a simple extension of the button class that overrides
// the ProcessMnemonic method. If the mnemonic is correctly entered,
// the message box will appear and the click event will be raised.
// This method makes sure the control is selectable and the
// mnemonic is correct before displaying the message box
// and triggering the click event.
public ref class MyMnemonicButton: public Button
{
protected:
bool ProcessMnemonic( char inputChar )
{
if ( CanSelect && IsMnemonic( inputChar, this->Text ) )
{
MessageBox::Show( "You've raised the click event "
"using the mnemonic." );
this->PerformClick();
return true;
}
return false;
}
};
// This button is a simple extension of the button class that overrides
// the ProcessMnemonic method. If the mnemonic is correctly entered,
// the message box will appear and the click event will be raised.
public class MyMnemonicButton : Button
{
// This method makes sure the control is selectable and the
// mneumonic is correct before displaying the message box
// and triggering the click event.
protected override bool ProcessMnemonic(char inputChar)
{
if (CanSelect && IsMnemonic(inputChar, this.Text))
{
MessageBox.Show("You've raised the click event " +
"using the mnemonic.");
this.PerformClick();
return true;
}
return false;
}
}
' This button is a simple extension of the button class that overrides
' the ProcessMnemonic method. If the mnemonic is correctly entered,
' the message box will appear and the click event will be raised.
Public Class MyMnemonicButton
Inherits Button
' This method makes sure the control is selectable and the
' mneumonic is correct before displaying the message box
' and triggering the click event.
<System.Security.Permissions.UIPermission( _
System.Security.Permissions.SecurityAction.Demand, Window:=UIPermissionWindow.AllWindows)> _
Protected Overrides Function ProcessMnemonic( _
ByVal inputChar As Char) As Boolean
If (CanSelect And IsMnemonic(inputChar, Me.Text)) Then
MessageBox.Show("You've raised the click event " _
& "using the mnemonic.")
Me.PerformClick()
Return True
End If
Return False
End Function
End Class
Megjegyzések
Ennek a módszernek az a célja, hogy lehetőséget adjon egy vezérlőnek egy mnemonikus karakter feldolgozására. A metódusnak meg kell határoznia, hogy a vezérlő állapota a benemonicsok feldolgozásához szükséges-e, és hogy az adott karakter egy mnemonikus karaktert jelöl-e. Ha igen, a metódusnak végre kell hajtania a mnemonichoz társított műveletet, és vissza kell adnia true. Ha nem, a metódusnak vissza kell térnie false. A metódus implementációi gyakran használják a IsMnemonic metódust annak meghatározására, hogy az adott karakter megfelel-e a vezérlő szövegében lévő mnemonikus karakternek.
Például:
if (CanSelect && IsMnemonic(charCode, MyControl.Text) {
// Perform action associated with mnemonic.
}
A metódus alapértelmezett implementációja ProcessMnemonic egyszerűen azt false jelzi, hogy a vezérlő nem tartalmaz mnemonikus értéket.