怎么用C#编写记事本或者画图??!!
怎么用C#编写记事本或者画图??!!怎么用C#编写记事本或者画图??!!求怎么用C#编richtextbox啊。。。。而不是用那控件。。。。有没有哪有源代码。。。。...
怎么用C#编写记事本或者画图??!!怎么用C#编写记事本或者画图??!!
求怎么用C#编richtextbox啊。。。。而不是用那控件。。。。有没有哪有源代码。。。。 展开
求怎么用C#编richtextbox啊。。。。而不是用那控件。。。。有没有哪有源代码。。。。 展开
6个回答
展开全部
我这里有以前写的 记事本
源码如下: 谢谢采纳~~~
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Timers;
namespace 记事本
{
public partial class cc : Form
{
public cc()
{
InitializeComponent();
}
private void 新建ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.richTextBox1.Text = "";
}
private string Url;
private void 打开ToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "打开|*.txt";
if (ofd.ShowDialog() == DialogResult.OK)
{
this.richTextBox1.LoadFile(ofd.FileName,RichTextBoxStreamType.PlainText);
Url = ofd.FileName;
}
}
private void 保存ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (Url == null)
{
SaveFileDialog sa = new SaveFileDialog();
sa.Filter = "保存(*.txt)|*.txt";
if (sa.ShowDialog() == DialogResult.OK)
{
this.richTextBox1.SaveFile(sa.FileName, RichTextBoxStreamType.PlainText);
Url = sa.FileName;
}
}
else
{
this.richTextBox1.SaveFile(Url, RichTextBoxStreamType.PlainText);
}
}
private void 另存为ToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog sa = new SaveFileDialog();
sa.Filter = "另存为(*.txt)|*.txt";
if (sa.ShowDialog() == DialogResult.OK)
{
this.richTextBox1.SaveFile(sa.FileName, RichTextBoxStreamType.PlainText);
}
}
private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
private void 剪切ToolStripMenuItem_Click(object sender, EventArgs e)
{
Clipboard.SetText(this.richTextBox1.SelectedText);
this.richTextBox1.SelectedText = "";
}
private void 复制ToolStripMenuItem_Click(object sender, EventArgs e)
{
Clipboard.SetText(this.richTextBox1.SelectedText);
}
private void 粘贴ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.richTextBox1.SelectedText = Clipboard.GetText();
}
private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.richTextBox1.SelectedText = "";
}
private void Form1_Load(object sender, EventArgs e)
{
this.剪切ToolStripMenuItem.Enabled = false;
this.复制ToolStripMenuItem.Enabled = false;
this.粘贴ToolStripMenuItem.Enabled = false;
this.剪切ToolStripMenuItem1.Enabled = false;
this.复制ToolStripMenuItem1.Enabled = false;
this.粘贴ToolStripMenuItem1.Enabled = false;
}
private void richTextBox1_SelectionChanged(object sender, EventArgs e)
{
if (this.richTextBox1.SelectedText == "")
{
this.剪切ToolStripMenuItem.Enabled = false;
this.复制ToolStripMenuItem.Enabled = false;
this.粘贴ToolStripMenuItem.Enabled = true;
this.剪切ToolStripMenuItem1.Enabled = false;
this.复制ToolStripMenuItem1.Enabled = false;
this.粘贴ToolStripMenuItem1.Enabled = true;
}
else
{
this.剪切ToolStripMenuItem.Enabled = true;
this.复制ToolStripMenuItem.Enabled = true;
this.粘贴ToolStripMenuItem.Enabled = true;
this.剪切ToolStripMenuItem1.Enabled = true;
this.复制ToolStripMenuItem1.Enabled = true;
this.粘贴ToolStripMenuItem1.Enabled = true;
}
}
private void 自动换行ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.自动换行ToolStripMenuItem.Checked = !(this.自动换行ToolStripMenuItem.Checked);
this.richTextBox1.WordWrap = !(this.richTextBox1.WordWrap);
}
private void 字体ToolStripMenuItem_Click(object sender, EventArgs e)
{
FontDialog fd = new FontDialog();
fd.ShowDialog();
if (this.richTextBox1.SelectedText == "")
{
this.richTextBox1.Font = fd.Font;
}
else
{
this.richTextBox1.SelectionFont = fd.Font;
}
}
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
MessageBox.Show("谢谢使用!" + DateTime.Now);
}
private void 看看ToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("@2009-05-18");
}
private void cc_FormClosing(object sender, FormClosingEventArgs e)
{
}
private void xuao520163comToolStripMenuItem_Click(object sender, EventArgs e)
{
}
}
}
源码如下: 谢谢采纳~~~
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Timers;
namespace 记事本
{
public partial class cc : Form
{
public cc()
{
InitializeComponent();
}
private void 新建ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.richTextBox1.Text = "";
}
private string Url;
private void 打开ToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "打开|*.txt";
if (ofd.ShowDialog() == DialogResult.OK)
{
this.richTextBox1.LoadFile(ofd.FileName,RichTextBoxStreamType.PlainText);
Url = ofd.FileName;
}
}
private void 保存ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (Url == null)
{
SaveFileDialog sa = new SaveFileDialog();
sa.Filter = "保存(*.txt)|*.txt";
if (sa.ShowDialog() == DialogResult.OK)
{
this.richTextBox1.SaveFile(sa.FileName, RichTextBoxStreamType.PlainText);
Url = sa.FileName;
}
}
else
{
this.richTextBox1.SaveFile(Url, RichTextBoxStreamType.PlainText);
}
}
private void 另存为ToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog sa = new SaveFileDialog();
sa.Filter = "另存为(*.txt)|*.txt";
if (sa.ShowDialog() == DialogResult.OK)
{
this.richTextBox1.SaveFile(sa.FileName, RichTextBoxStreamType.PlainText);
}
}
private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
private void 剪切ToolStripMenuItem_Click(object sender, EventArgs e)
{
Clipboard.SetText(this.richTextBox1.SelectedText);
this.richTextBox1.SelectedText = "";
}
private void 复制ToolStripMenuItem_Click(object sender, EventArgs e)
{
Clipboard.SetText(this.richTextBox1.SelectedText);
}
private void 粘贴ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.richTextBox1.SelectedText = Clipboard.GetText();
}
private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.richTextBox1.SelectedText = "";
}
private void Form1_Load(object sender, EventArgs e)
{
this.剪切ToolStripMenuItem.Enabled = false;
this.复制ToolStripMenuItem.Enabled = false;
this.粘贴ToolStripMenuItem.Enabled = false;
this.剪切ToolStripMenuItem1.Enabled = false;
this.复制ToolStripMenuItem1.Enabled = false;
this.粘贴ToolStripMenuItem1.Enabled = false;
}
private void richTextBox1_SelectionChanged(object sender, EventArgs e)
{
if (this.richTextBox1.SelectedText == "")
{
this.剪切ToolStripMenuItem.Enabled = false;
this.复制ToolStripMenuItem.Enabled = false;
this.粘贴ToolStripMenuItem.Enabled = true;
this.剪切ToolStripMenuItem1.Enabled = false;
this.复制ToolStripMenuItem1.Enabled = false;
this.粘贴ToolStripMenuItem1.Enabled = true;
}
else
{
this.剪切ToolStripMenuItem.Enabled = true;
this.复制ToolStripMenuItem.Enabled = true;
this.粘贴ToolStripMenuItem.Enabled = true;
this.剪切ToolStripMenuItem1.Enabled = true;
this.复制ToolStripMenuItem1.Enabled = true;
this.粘贴ToolStripMenuItem1.Enabled = true;
}
}
private void 自动换行ToolStripMenuItem_Click(object sender, EventArgs e)
{
this.自动换行ToolStripMenuItem.Checked = !(this.自动换行ToolStripMenuItem.Checked);
this.richTextBox1.WordWrap = !(this.richTextBox1.WordWrap);
}
private void 字体ToolStripMenuItem_Click(object sender, EventArgs e)
{
FontDialog fd = new FontDialog();
fd.ShowDialog();
if (this.richTextBox1.SelectedText == "")
{
this.richTextBox1.Font = fd.Font;
}
else
{
this.richTextBox1.SelectionFont = fd.Font;
}
}
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
MessageBox.Show("谢谢使用!" + DateTime.Now);
}
private void 看看ToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("@2009-05-18");
}
private void cc_FormClosing(object sender, FormClosingEventArgs e)
{
}
private void xuao520163comToolStripMenuItem_Click(object sender, EventArgs e)
{
}
}
}
展开全部
graphic类
drawstring()
drawline()
。。。。。。
看看GDI+就会了
drawstring()
drawline()
。。。。。。
看看GDI+就会了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
记事本好搞,画图就。。。
我是新手,所以作此评价
我是新手,所以作此评价
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
确实,仔细看看GDI+.写记事本其实是很简单的。如果初学,可以找个源代码,先看,然后扩展功能,对自己帮助更大
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
记事本就用RichTextBox很方便
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
涉及到GDI了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询