
| 親メニュー | 子メニュー | メソッド | 説明 |
|---|---|---|---|
| テキスト(&T) | |||
| コピー(&C) | Text_Copy | 選択した TEXT をコピーします | |
| 削除(&D) | Text_Cut | 選択した TEXT を削除します | |
| 貼り付け(&P) | Text_Paste | コピーした TEXT を貼り付けます | |
| 元に戻す(&U) | Text_Undo | 編集を取り消してもとに戻します | |
| やり直す(&R) | Text_Redo | 取り消した編集を戻します | |
| 編集(&E) | Editor | 選択ファイルを Editor で起動します |
using System.Diagnostics; // Process の起動
string m_sou = "Source"; // 検索キー(パスワード)
string ED_Path = @"C:\WINDOWS\System32\notepad.exe";
//☆ テキスト編集
private void Text_Copy(object sender, EventArgs e)
{
if (richTextBox1.SelectionLength > 0)
{ richTextBox1.Copy();
m_sou = Clipboard.GetText();
}
}
private void Text_Cut(object sender, EventArgs e)
{
if (richTextBox1.SelectionLength > 0)
{ richTextBox1.Cut(); }
}
private void Text_Paste(object sender, EventArgs e)
{
ClipPaste();
}
private void ClipPaste()
{
IDataObject data = Clipboard.GetDataObject();
if (data != null && data.GetDataPresent(DataFormats.Text) == true)
{
int pos = richTextBox1.SelectionStart;
richTextBox1.Select(pos, 0);
richTextBox1.SelectedText = Clipboard.GetText();
}
richTextBox1.Modified = true;
}
private void Text_Undo(object sender, EventArgs e)
{
if (richTextBox1.CanUndo)
{ richTextBox1.Undo(); }
}
private void Text_Redo(object sender, EventArgs e)
{
if (richTextBox1.CanRedo)
{ richTextBox1.Redo(); }
}
private void Editor(object sender, EventArgs e)
{
string str;
str = richTextBox1.SelectedText.ToString();
if (File.Exists(str))
{ Process.Start(ED_Path, str);
return;
}
MessageBox.Show("ファイルが見つかりません");
}
|
private void Text_Paste(object sender, EventArgs e)
{
IDataObject data = Clipboard.GetDataObject();
if (data != null && data.GetDataPresent(DataFormats.Text) == true)
{ richTextBox1.Paste(); }
}
|
using System.Diagnostics; // Process の起動 string ED_Path = @"c:\bin\edit.exe"; |
string ED_Path = @"C:\WINDOWS\System32\notepad.exe"; |
class form01
{
[STAThread]
public static void Main()
{
MyForm mf = new MyForm();
Application.Run(mf);
}
}
|
private void InitializeComponent()
{
・・・
// richTextBox1
this.richTextBox1.ContextMenuStrip = this.contextMenuStrip1;
・・・
|
※・