PowerTools InputMan for Windows Forms 8.0J
ClearUndo メソッド (EditBase)
使用例 

コントロールのアンドゥ バッファから直前に実行された操作に関する情報を削除します。
構文
Public Sub ClearUndo() 
public void ClearUndo()
解説
ClearUndo メソッドを使用すると、アプリケーションの状態に基づいて、元に戻す操作が繰り返されるのを防ぐことができます。
使用例
派生クラス GcTextBox を使用するコード例を次に示します。切り取り、コピー、貼り付け、元に戻す、テキストの選択開始点や選択文字数の設定などの各操作を実行する System.Windows.Forms.MenuItem.Click オブジェクトの System.Windows.Forms.MenuItem イベント ハンドラを用意します。
//  Please use the following namespace
//  using System.Windows.Forms;
//  using GrapeCity.Win.Editors;

private GcTextBox gcTextBox1 = new GcTextBox();
private void Menu_Copy(System.Object sender, System.EventArgs e)
{
    // Ensure that text is selected in the text box.   
    if (gcTextBox1.SelectionLength > 0)
        // Copy the selected text to the Clipboard.
        gcTextBox1.Copy();
}

private void Menu_Cut(System.Object sender, System.EventArgs e)
{
    // Ensure that text is currently selected in the text box.   
    if (gcTextBox1.SelectedText != "")
        // Cut the selected text in the control and paste it into the Clipboard.
        gcTextBox1.Cut();
}

private void Menu_Paste(System.Object sender, System.EventArgs e)
{
    // Determine if there is any text in the Clipboard to paste into the text box.
    if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text) == true)
    {
        // Determine if any text is selected in the text box.
        if (gcTextBox1.SelectionLength > 0)
        {
            // Ask user if they want to paste over currently selected text.
            if (MessageBox.Show("Do you want to paste over current selection?", "Cut Example", MessageBoxButtons.YesNo) == DialogResult.No)
                // Move selection to the point after the current selection and paste.
                gcTextBox1.SelectionStart = gcTextBox1.SelectionStart + gcTextBox1.SelectionLength;
        }
        // Paste current text in Clipboard into text box.
        gcTextBox1.Paste();
    }
}

private void Menu_Undo(System.Object sender, System.EventArgs e)
{
    // Determine if last operation can be undone in text box.   
    if (gcTextBox1.CanUndo == true)
    {
        // Undo the last operation.
        gcTextBox1.Undo();
        // Clear the undo buffer to prevent last action from being redone.
        gcTextBox1.ClearUndo();
    }
}
'  Please use the following namespace
'  Imports System.Windows.Forms;
'  Imports GrapeCity.Win.Editors;

Private gcTextBox1 As New GcTextBox()
Private Sub Menu_Copy(ByVal sender As System.Object, ByVal e As System.EventArgs)
    ' Ensure that text is selected in the text box.   
    If gcTextBox1.SelectionLength > 0 Then
        ' Copy the selected text to the Clipboard.
        gcTextBox1.Copy()
    End If
End Sub

Private Sub Menu_Cut(ByVal sender As System.Object, ByVal e As System.EventArgs)
    ' Ensure that text is currently selected in the text box.   
    If gcTextBox1.SelectedText <> "" Then
        ' Cut the selected text in the control and paste it into the Clipboard.
        gcTextBox1.Cut()
    End If
End Sub

Private Sub Menu_Paste(ByVal sender As System.Object, ByVal e As System.EventArgs)
    ' Determine if there is any text in the Clipboard to paste into the text box.
    If Clipboard.GetDataObject().GetDataPresent(DataFormats.Text) = True Then
        ' Determine if any text is selected in the text box.
        If gcTextBox1.SelectionLength > 0 Then
            ' Ask user if they want to paste over currently selected text.
            If MessageBox.Show("Do you want to paste over current selection?", "Cut Example", MessageBoxButtons.YesNo) = DialogResult.No Then
                ' Move selection to the point after the current selection and paste.
                gcTextBox1.SelectionStart = gcTextBox1.SelectionStart + gcTextBox1.SelectionLength
            End If
        End If
        ' Paste current text in Clipboard into text box.
        gcTextBox1.Paste()
    End If
End Sub

Private Sub Menu_Undo(ByVal sender As System.Object, ByVal e As System.EventArgs)
    ' Determine if last operation can be undone in text box.   
    If gcTextBox1.CanUndo = True Then
        ' Undo the last operation.
        gcTextBox1.Undo()
        ' Clear the undo buffer to prevent last action from being redone.
        gcTextBox1.ClearUndo()
    End If
End Sub
参照

EditBase クラス
EditBase メンバ
Paste メソッド
Copy メソッド
Clear メソッド
Undo メソッド
Cut メソッド

 

 


© 2004-2015 GrapeCity inc. All rights reserved.