⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hrichtextbox.cs

📁 c#编写的汽车销售公司erp进销存系统
💻 CS
📖 第 1 页 / 共 2 页
字号:
			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 + -