?? hrichtextbox.cs
字號:
this.toolBarButton14.Text = "查找";
this.toolBarButton14.ToolTipText = "查找";
//
// toolBarButton15
//
this.toolBarButton15.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
//
// toolBarButton16
//
this.toolBarButton16.Tag = "全選";
this.toolBarButton16.Text = "全選";
this.toolBarButton16.ToolTipText = "全選";
//
// toolBarButton18
//
this.toolBarButton18.Tag = "清空";
this.toolBarButton18.Text = "清空";
this.toolBarButton18.ToolTipText = "清空";
//
// toolBarButton19
//
this.toolBarButton19.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
//
// toolBarButton20
//
this.toolBarButton20.Tag = "撤消";
this.toolBarButton20.Text = "撤消";
this.toolBarButton20.ToolTipText = "撤消";
//
// toolBarButton21
//
this.toolBarButton21.Tag = "恢復";
this.toolBarButton21.Text = "恢復";
this.toolBarButton21.ToolTipText = "恢復";
//
// contextMenu1
//
this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1,
this.menuItem2,
this.menuItem3});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.Text = "復制";
this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
//
// menuItem2
//
this.menuItem2.Index = 1;
this.menuItem2.Text = "剪切";
this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
//
// menuItem3
//
this.menuItem3.Index = 2;
this.menuItem3.Text = "粘貼";
this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
//
// imageList1
//
this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
//
// richTextBox1
//
this.richTextBox1.ContextMenu = this.contextMenu1;
this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.richTextBox1.Location = new System.Drawing.Point(3, 3);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(658, 305);
this.richTextBox1.TabIndex = 1;
this.richTextBox1.Text = "";
//
// panelControl1
//
this.panelControl1.Controls.Add(this.richTextBox1);
this.panelControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panelControl1.Location = new System.Drawing.Point(0, 41);
this.panelControl1.Name = "panelControl1";
this.panelControl1.Size = new System.Drawing.Size(664, 311);
this.panelControl1.TabIndex = 2;
this.panelControl1.Text = "panelControl1";
//
// HRichTextBox
//
this.BackColor = System.Drawing.SystemColors.Control;
this.Controls.Add(this.panelControl1);
this.Controls.Add(this.toolBar1);
this.Name = "HRichTextBox";
this.Size = new System.Drawing.Size(664, 352);
((System.ComponentModel.ISupportInitialize)(this.panelControl1)).EndInit();
this.panelControl1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
try
{
DialogResult dresult=new DialogResult();
switch (e.Button.Tag.ToString())
{
case "字體":
dresult=this.fontDialog1.ShowDialog();
if(dresult==DialogResult.OK)
{
this.richTextBox1.Font=this.fontDialog1.Font;
}
break;
case "顏色":
dresult=this.colorDialog1.ShowDialog();
if(dresult==DialogResult.OK)
{
this.richTextBox1.ForeColor=this.colorDialog1.Color;
}
break;
case "居左":
this.richTextBox1.SelectionAlignment=HorizontalAlignment.Left;
break;
case "居中":
this.richTextBox1.SelectionAlignment=HorizontalAlignment.Left;
break;
case "居右":
this.richTextBox1.SelectionAlignment=HorizontalAlignment.Left;
break;
case "剪切":
this.richTextBox1.Cut();
break;
case "粘貼":
this.richTextBox1.Paste();
break;
case "復制":
this.richTextBox1.Copy();
break;
case "導出":
this.saveFileDialog1.DefaultExt="rtf";
this.saveFileDialog1.Filter="word文件(*.rtf)|*.rtf|所有文件(*.*)|*.*";
this.saveFileDialog1.Title="導出文件";
dresult=this.saveFileDialog1.ShowDialog();
if(dresult==DialogResult.OK)
{
this.richTextBox1.SaveFile(this.saveFileDialog1.FileName);
MessageBox.Show("導出成功");
}
break;
case "查找":
FindForm findform=new FindForm(this);
findform.Show();
break;
case "全選":
this.richTextBox1.SelectAll();
break;
case "清空":
this.richTextBox1.Clear();
break;
case "撤消":
this.richTextBox1.Undo();
break;
case "恢復":
this.richTextBox1.Redo();
break;
case "導入":
this.openFileDialog1.DefaultExt="rtf";
this.openFileDialog1.Filter="word文件(*.rtf)|*.rtf";
this.openFileDialog1.Title="導入文件";
dresult=this.openFileDialog1.ShowDialog();
if(dresult==DialogResult.OK)
{
this.richTextBox1.LoadFile(this.openFileDialog1.FileName);
MessageBox.Show("導入成功");
}
break;
default:
break;
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void menuItem1_Click(object sender, System.EventArgs e)
{
this.richTextBox1.Copy();
}
private void menuItem2_Click(object sender, System.EventArgs e)
{
this.richTextBox1.Cut();
}
private void menuItem3_Click(object sender, System.EventArgs e)
{
this.richTextBox1.Paste();
}
public string RtfText
{
get
{
return this.richTextBox1.Rtf;
}
set
{
this.richTextBox1.Rtf=value;
}
}
public override string Text
{
get
{
return this.richTextBox1.Text;
}
set
{
this.richTextBox1.Text=value;
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -