ComponentOne Ribbon for WinForms
C1Ribbon (Classic) Task-Based Help / Handling Ribbon Events / Handling the RibbonButton.Click Event
In This Topic
    Handling the RibbonButton.Click Event
    In This Topic
    Note: This topic assumes that you have added three Ribbon buttons to the Ribbon and a RichTextBox control to the Ribbon Form. For steps on how to add a Ribbon control to the Ribbon, see Adding Items to the Ribbon Group.

    To copy, cut, or paste text in the rich text box, create RibbonButton.Click event handlers for the Copy, Cut, and Paste buttons. Add the following code to your project:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    ' type the Imports directive for the namespace
    Imports C1.Win.C1Ribbon
     
    ' handles the Click event for the Copy button
    Private Sub CopyBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyBtn.Click
        Me.RichTextBox1.Copy()
        Me.RichTextBox1.Focus()
    End Sub
     
    ' handles the Click event for the Cut button
    Private Sub CutBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cutbtn.Click
        Me.RichTextBox1.Cut()
        Me.RichTextBox1.Focus()
    End Sub
     
    ' handles the Click event for the Paste button
    Private Sub PasteBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PasteBtn.Click
        Me.RichTextBox1.Paste()
        Me.RichTextBox1.Focus()
    End Sub
    

    To write code in C#

    C#
    Copy Code
    // type the using directive for the namespace
    using C1.Win.C1Ribbon;
     
    // handles the Click event for the Copy button
    private void CopyBtn_Click(object sender, EventArgs e)
    {
        this.richTextBox1.Copy();
        this.richTextBox1.Focus();
    }
     
    // handles the Click event for the Cut button
    private void CutBtn_Click(object sender, EventArgs e)
    {
        this.richTextBox1.Cut();
        this.richTextBox1.Focus();
    }
     
    // handles the Click event for the Paste button
    private void PasteBtn_Click(object sender, EventArgs e)
    {
        this.richTextBox1.Paste();
        this.richTextBox1.Focus();
    }
    

    Note that the following properties have been set for the RibbonButton.Name properties: