I have a rich text box(richTextBox1
) in my program as shown bellow. But when I right click on it, it doesn\'t pop up a “copy, cut, past” window. Can you please tell
I just want to add to Thilina H's answer (the one that was marked as the correct answer by the poster) Here is my copy and paste functions, They are a bit more notepad like.
void CopyAction(object sender, EventArgs e)
{
if (richTextBox1.SelectedText != null && richTextBox1.SelectedText != "")
{
Clipboard.SetText(richTextBox1.SelectedText);
}
}
void PasteAction(object sender, EventArgs e)
{
if (Clipboard.ContainsText())
{
int selstart = richTextBox1.SelectionStart;
if (richTextBox1.SelectedText != null && richTextBox1.SelectedText != "")
{
richTextBox1.Text = richTextBox1.Text.Remove(selstart, richTextBox1.SelectionLength);
}
string clip = Clipboard.GetText(TextDataFormat.Text).ToString();
richTextBox1.Text = richTextBox1.Text.Insert(selstart, clip);
richTextBox1.SelectionStart = selstart + clip.Length;
}
}
I hope it helps someone ;