共用方式為


PenInputPanelInputFailedEventHandler 委派

表示處理 PenInputPanel 物件之 InputFailed 事件的方法。

命名空間:  Microsoft.Ink
組件:  Microsoft.Ink (在 Microsoft.Ink.dll 中)

語法

'宣告
Public Delegate Sub PenInputPanelInputFailedEventHandler ( _
    sender As Object, _
    e As PenInputPanelInputFailedEventArgs _
)
'用途
Dim instance As New PenInputPanelInputFailedEventHandler(AddressOf HandlerMethod)
public delegate void PenInputPanelInputFailedEventHandler(
    Object sender,
    PenInputPanelInputFailedEventArgs e
)
public delegate void PenInputPanelInputFailedEventHandler(
    Object^ sender, 
    PenInputPanelInputFailedEventArgs^ e
)
/** @delegate */
public delegate void PenInputPanelInputFailedEventHandler(
    Object sender,
    PenInputPanelInputFailedEventArgs e
)
JScript 不支援委派。

參數

備註

若輸入焦點在使用者輸入插入附加的控制項之前就已變更,則會發生 InputFailed 事件。例如,使用者將「筆墨」輸入書寫板,然後在辨識器尚未完成之前點選另一個編輯控制項,便會引發這個事件。

透過使用傳入這個事件的視窗控制代碼,您就可以選擇在這個事件發生時自行插入文字。

範例

這個 C# 範例會建立兩個 PenInputPanel 物件 (thePenInputPanel1 和 thePenInputPanel2),並且將它們附加至 TextBox (英文) 控制項 (textBox1 和 textBox2)。然後再將 InputFailed 事件處理常式 (InputFailed_Event) 加入至每個 PenInputPanel。在事件處理常式中,如果焦點已變更,則會藉由設定 Text (英文) 屬性,在前一個 TextBox (英文) 控制項中設定文字。

[C#]

//...

// Declare PenInputPanel objects
PenInputPanel thePenInputPanel1;
PenInputPanel thePenInputPanel2;

public Form1()
{
    // Required for Windows Form Designer support
    InitializeComponent();

    // Create, and attach new PenInputPanels to a TextBox controls.
    thePenInputPanel1 = new PenInputPanel(textBox1);
    thePenInputPanel2 = new PenInputPanel(textBox2);

    // Add an InputFailed event handler to each PenInputPanel
    thePenInputPanel1.InputFailed +=
        new PenInputPanelInputFailedEventHandler(InputFailed_Event);

    thePenInputPanel2.InputFailed +=
        new PenInputPanelInputFailedEventHandler(InputFailed_Event);
}

//...

public void InputFailed_Event(object sender,
PenInputPanelInputFailedEventArgs e)
{
    // Make sure the object that generated
    // the event is a PenInputPanel object
    if (sender is PenInputPanel)
    {
        PenInputPanel theSenderPanel = (PenInputPanel)sender;

        // Set the text in the previous control
        theSenderPanel.AttachedEditControl.Text += e.Text;
    }
}

這個 Microsoft® Visual Basic® .NET 範例會建立兩個 PenInputPanel 物件 (thePenInputPanel1 和 thePenInputPanel2),並且將它們附加至 TextBox (英文) 控制項 (TextBox1 和 TextBox2)。然後再將 InputFailed 事件處理常式 (InputFailed_Event) 加入至每個 PenInputPanel。在事件處理常式中,如果焦點已變更,則會藉由設定 Text (英文) 屬性,在前一個 TextBox (英文) 控制項中設定文字。

[Visual Basic]

'...

' Declare the PenInputPanel objects
Dim thePenInputPanel1 As PenInputPanel
Dim thePenInputPanel2 As PenInputPanel

Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    ' Create and attach new PenInputPanels to a TextBox controls.
    thePenInputPanel1 = New PenInputPanel(TextBox1)
    thePenInputPanel2 = New PenInputPanel(TextBox2)

    ' Add an InputFailed event handler to each PenInputPanel
    AddHandler thePenInputPanel1.InputFailed, AddressOf InputFailed_Event
    AddHandler thePenInputPanel2.InputFailed, AddressOf InputFailed_Event
End Sub 'New

'...

Public Sub InputFailed_Event(ByVal sender As Object, ByVal e As _
                             PenInputPanelInputFailedEventArgs)
    ' Make sure the object that generated
    ' the event is a PenInputPanel object
    If TypeOf sender Is PenInputPanel Then
        Dim thePenInputPanel As PenInputPanel = CType(sender, PenInputPanel)

        ' Set the text in the previous control
        thePenInputPanel.AttachedEditControl.Text += e.Text
    End If
End Sub 'InputFailed_Event

平台

Windows Vista

.NET Framework 和 .NET Compact Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱 .NET Framework 系統需求

版本資訊

.NET Framework

支援版本:3.0

請參閱

參考

Microsoft.Ink 命名空間

PenInputPanel.OnInputFailed