Font printFont ;privatevoid pd_PrintPage(object sender, PrintPageEventArgs ev){ ev.Graphics.DrawString (richTextBox1.Text);ev.HasMorePages = true;} publicvoid Printing(){ printFont = new Font("Arial", 10);PrintDocument pd = new PrintDocument();pd.PrintPage += new PrintPageEvent...
bool IsKeyEnter = false;int maxLength = 80; //限制长度 private void richTextBox1_KeyPress(object sender, KeyPressEventArgs e){ //判断是否按下 Enter if (e.KeyChar == 13){ IsKeyEnter = true;} } private void richTextBox1_TextChanged(object sender, EventArgs e){ //不为...
具体的方法如下:用户界面:选取的文字需要变色,或者加上下划线。下面的代码是具体的实现步骤。首先,选取文字,Cut方法剪掉 string s = editViewer.Selection.Text;editViewer.Cut();然后,在光标位置上创建同样文字的Run的实例 Run r = new Run(s, editViewer.CaretPosition);我这里是把文字的颜色改...
DrawString(ptline.content, ptline.font, ptline.color, X, Y, new StringFormat());Y += ptline.font.GetHeight(ev.Graphics);} ev.HasMorePages = false;} 对于你的业务,在PrintPage里判断当前能否进行打印(有无内容,存折有无空间,翻到下页没有),并设置ev.HasMorePages为适当值。
{ public Form1(){ InitializeComponent();form2 = new Form2();form2.Show();} private Form2 form2;private void listBox_SelectedIndexChanged(object sender, EventArgs e){ form2.SetRBText(listBox.SelectedItem.ToString());} } Form2里边有一个RichTextBox,叫richTextBox public partial ...
sqlconnection conn=new sqlconnction(str_conn);conn.open();const string insert_sql="insert into 表名 (字段名) values (@0)";sqlcommand cmd=new sqlcommand(insert_sql,conn);cmd.Parameters.AddWithValue("@0",richtextbox.Text);cmd.执行并返回影响行数那个方法,我记不太清楚名字 好像是ex...
在运行时,用 OLEObject 集合的 Add 方法,将嵌入对象,比如位图、图标、应用程序图标,加到该控件中。在设计时或运行时,可以拖放任何嵌入对象到控件中,包括文档,比如 Microsoft Excel 的电子表格和 Microsoft Word 文档等。=== richtextbox的OLE插入方式有三种:1、拖放:该对象在richtextbox中将显示...
path = path +"\\" +listBox1.Items[index].ToString();StreamReader sr = new StreamReader(path, Encoding.Default);String txt_string = "";string line = "";//按行读 while ((line = sr.ReadLine()) != null){ txt_string += line + "\n";} //写入richTextBox1 richTextBox...
string path;Directory.CreateDirectory(@"D://hp文件夹");path = "D://hp文件夹//" + this.textBox1.Text + ".doc";this.richTextBox1.SaveFile(@path, RichTextBoxStreamType.RichText);这样就可以存成word格式。编译通过
我在c#中使用richtextbox的时候用一个方法就搞定了。richTextBox1.Undo();