So, what I need is how to handle right clicks and then how to handle the buttons that are in the right click menu.
Thank you in advance,
here is my code if anyone needs it to help.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace TextPad
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void newToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox.Clear();
}
private void openToolStripMenuItem_Click_1(object sender, EventArgs e)
{
openFileDialog.Title = "Open File";
openFileDialog.Filter = "Text Document (.txt)|*.txt|Rich Text Document (.rtf)|*.rtf|Word Document (.doc)|*.doc|Batch File (.bat)|*.bat|All Files (*.*)|*.*";
if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
richTextBox.LoadFile(openFileDialog.FileName);
}
}
private void saveToolStripMenuItem_Click_1(object sender, EventArgs e)
{
saveFileDialog.Filter = "Text Document (.txt)|*.txt|Rich Text Document (.rtf)|*.rtf|Word Document (.doc)|*.doc|Batch File (.bat)|*.bat|All Files (*.*)|*.*";
saveFileDialog.Title = "Save File";
saveFileDialog.OverwritePrompt = true;
if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
richTextBox.SaveFile(saveFileDialog.FileName, RichTextBoxStreamType.RichText);
}
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Close();
}
private void undoToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox.Undo();
}
private void redoToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox.Redo();
}
private void cutToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox.Cut();
}
private void copyToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox.Copy();
}
private void paseToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox.Paste();
}
private void selectAllToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox.SelectAll();
}
private void clearToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox.Clear();
}
private void fontToolStripMenuItem_Click(object sender, EventArgs e)
{
FontDialog Font = new FontDialog();
Font.Font = richTextBox.SelectionFont;
if (Font.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
richTextBox.SelectionFont = (Font)Font.Font.Clone();
}
}
private void colorToolStripMenuItem_Click(object sender, EventArgs e)
{
ColorDialog Color = new ColorDialog();
Color.Color = richTextBox.SelectionColor;
if (Color.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
richTextBox.SelectionColor = Color.Color;
}
}
}
}

New Topic/Question
Reply




MultiQuote




|