C# richtextbox控件字体颜色问题

C# RichTextBox显示不同颜色文字_小组_ThinkSAAS
C# RichTextBox显示不同颜色文字
C# RichTextBox显示不同颜色文字
&无详细内容&
#region 日志记录、支持其他线程访问
public delegate void LogAppendDelegate(Color color, string text);
/// &summary&
/// 追加显示文本
/// &/summary&
/// &param name="color"&文本颜色&/param&
/// &param name="text"&显示文本&/param&
public void LogAppend(Color color, string text)
richTextBoxRemote.AppendText("n");
richTextBoxRemote.SelectionColor =
richTextBoxRemote.AppendText(text);
/// &summary&
/// 显示错误日志
/// &/summary&
/// &param name="text"&&/param&
public void LogError(string text)
LogAppendDelegate la = new LogAppendDelegate(LogAppend);
richTextBoxRemote.Invoke(la, Color.Red, DateTime.Now.ToString("HH:mm:ss") + text);
/// &summary&
/// 显示警告信息
/// &/summary&
/// &param name="text"&&/param&
public void LogWarning(string text)
LogAppendDelegate la = new LogAppendDelegate(LogAppend);
richTextBoxRemote.Invoke(la, Color.Violet, DateTime.Now.ToString("HH:mm:ss") + text);
/// &summary&
/// 显示信息
/// &/summary&
/// &param name="text"&&/param&
public void LogMessage(string text)
LogAppendDelegate la = new LogAppendDelegate(LogAppend);
richTextBoxRemote.Invoke(la, Color.Black, DateTime.Now.ToString("HH:mm:ss") + text);
#endregion
用户评论(0)
开发技术学习小组列表
PHP开发框架
缓存Memcache
服务器环境
ThinkSAAS商业授权:
ThinkSAAS为用户提供有偿个性定制开发服务
ThinkSAAS将为商业授权用户提供二次开发指导和技术支持
手机客户端
ThinkSAAS接收任何功能的Iphone(IOS)和Android手机的客户端定制开发服务
让ThinkSAAS更好,把建议拿来。
iphone扫码下载客户端C#怎样把文字和图片读出来显示在richtextbox里,就像word一样
利用C#怎样打开word文档,并且把其中的图片,文字等信息完整的显示出来,我用的是RichTextBox控件,请高手指导,一定要给出完整源代码哦,小弟初学者,帮帮忙啊!!!小弟刚来,只有这么多分,还请帮帮忙
09-05-03 & 发布
richtextbox本身就有表格显示的功能。你在word中制作好表格,在复制到richtextbox中就Ok了。因为richtextbox支持rtf格式。rtf可以实现字体结构的不同程序间相互的转移。 你要想点个什么事件后产生表格,就要自己写了。使用DHTML COM using S using System.Collections.G ponentM using System.D using System.D using System.T using System.Windows.F namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); richTextBox2.Rtf = &{\\rtf1\\ansi\\ansicpg936\\deff0\\deflang1033\\deflangfe2052{\\fonttbl{\\f0\\fnil\\fprq2\\fcharset134 \\'cb\\'ce\\'cc\\'e5;}{\\f1\\fnil\\fcharset134 \\'cb\\'ce\\'cc\\'e5;}}\\viewkind4\\uc1\\trowd\\trgaph108\\trleft-108\\trbrdrt\\brdrs\\brdrw10 \\trbrdrl\\brdrs\\brdrw10 \\trbrdrb\\brdrs\\brdrw10 \\trbrdrr\\brdrs\\brdrw10 \\clbrdrt\\brdrw15\\brdrs\\clbrdrl\\brdrw15\\brdrs\\clbrdrb\\brdrw15\\brdrs\\clbrdrr\\brdrw15\\brdrs \\cellx2732\\clbrdrt\\brdrw15\\brdrs\\clbrdrl\\brdrw15\\brdrs\\clbrdrb\\brdrw15\\brdrs\\clbrdrr\\brdrw15\\brdrs \\cellx5573\\clbrdrt\\brdrw15\\brdrs\\clbrdrl\\brdrw15\\brdrs\\clbrdrb\\brdrw15\\brdrs\\clbrdrr\\brdrw15\\brdrs \\cellx8414\\pard\\intbl\\kerning2\\f0\\fs21\\cell\\cell\\cell\\row\\intbl\\cell\\cell\\cell\\row\\pard\\lang2052\\kerning0\\f1\\fs18\\par}&; } private void richTextBox1_TextChanged(object sender, EventArgs e) { //richTextBox2.Text = richTextBox1.T richTextBox2.Text = richTextBox1.R //toolStripStatusLabel1.Text = richTextBox1.T } ponentModel.IContainer components = /// &summary& /// 清理所有正在使用的资源。 /// &/summary& /// &param name=&disposing&&如果应释放托管资源,为 true;否则为 false。&/param& protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows 窗体设计器生成的代码 /// &summary& /// 设计器支持所需的方法 - 不要 /// 使用代码编辑器修改此方法的内容。 /// &/summary& private void InitializeComponent() { this.richTextBox1 = new System.Windows.Forms.RichTextBox(); this.richTextBox2 = new System.Windows.Forms.RichTextBox(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); this.statusStrip1.SuspendLayout(); this.SuspendLayout(); // // richTextBox1 // this.richTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.richTextBox1.Location = new System.Drawing.Point(0, 0);
= &richTextBox1&; this.richTextBox1.Size = new System.Drawing.Size(292, 161); this.richTextBox1.TabIndex = 0; this.richTextBox1.Text = &&; this.richTextBox1.TextChanged += new System.EventHandler(this.richTextBox1_TextChanged); // // richTextBox2 // this.richTextBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.richTextBox2.Location = new System.Drawing.Point(0, 157);
= &richTextBox2&; this.richTextBox2.Size = new System.Drawing.Size(292, 91); this.richTextBox2.TabIndex = 1; this.richTextBox2.Text = &&; // // statusStrip1 // this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripStatusLabel1}); this.statusStrip1.Location = new System.Drawing.Point(0, 251);
= &statusStrip1&; this.statusStrip1.Size = new System.Drawing.Size(292, 22); this.statusStrip1.TabIndex = 2; this.statusStrip1.Text = &statusStrip1&; // // toolStripStatusLabel1 //
= &toolStripStatusLabel1&; this.toolStripStatusLabel1.Size = new System.Drawing.Size(131, 17); this.toolStripStatusLabel1.Text = &toolStripStatusLabel1&; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.F this.ClientSize = new System.Drawing.Size(292, 273); this.Controls.Add(this.statusStrip1); this.Controls.Add(this.richTextBox2); this.Controls.Add(this.richTextBox1); this.Name = &Form1&; this.Text = &Form1&; this.statusStrip1.ResumeLayout(false); this.statusStrip1.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.RichTextBox richTextBox1; private System.Windows.Forms.RichTextBox richTextBox2; private System.Windows.Forms.StatusStrip statusStrip1; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; } } 需要什么(图片,表格)就复制到框1里,框2就会显示出代码。这样你可能会更明白吧!
请登录后再发表评论!
richTextBox1.SaveFile(&文件名&); 只不过,richTextBox里的信息都是保存成doc文件的,这样可以用word打开
请登录后再发表评论!问题补充&&
&quot.toolStripComboBox2, 18, 36, &quot.5F;72&quot, 22;24&quot
给Combox添加Item的时候在初始化时执行一次就OK了, &quot, &七号&quot, &quot, &, 26.SelectionFont, 24;; };;二号&quot.Add(name);*System。
public Form1()
InitializeComponent().InstalledFontCollection();9&20&quot.I
foreach (string name in FontSizeName)
{八号&五号&, 14, EventArgs e)
{/48&, &quot.Drawing.Text, 5.D, &quot, &
public string[] FontSizeName = { &quot.InstalledFontCollection fonts = new System, &14&quot.Items, 22, 36.toolStripComboBox2;, 5 }, 14;
System, &quot.InstalledFontCollection(), &quot, &quot, 28.SelectedIndex],
如果放在DropDown事件里就会DropDown一次执行一次, 12, &;/.Text, &quot, EventArgs e)
private void toolStripComboBox2_DropDown(object **nder, &quot, 72, 16.Add(name);, &**&三号&.Text, &, 26;
foreach (string name in FontSizeName)
this.5F, EventArgs e)
this, &四号&.Style);小二&quot,
改成下面方式没有发现你所描述的问题;一号&quot.richTextBox1.T;, &quot, 20, 9;36&quot, &;;定义字号数组
private void toolStripComboBox1_DropDown(object **小四&
}*&#47.5F;, 10.Drawing, 12, &小初&;
/小一&quot, &quot, &, &;, 7;10&quot, 48;8&六号&;
private void toolStripComboBox2_SelectedIndexChanged(object **18&......余下全文>>
菲尔小落 &
•回答
•回答
•回答
•回答
•回答
猜你感兴趣
服务声明: 信息来源于互联网,不保证内容的可靠性、真实性及准确性,仅供参考,版权归原作者所有!Copyright &
Powered by当前位置: >
> c# RichTextbox怎么读取一段文字
c# RichTextbox怎么读取一段文字
love_sport & at
c# RichTextbox如何读取一段文字?如何读取一段文字,代码如何实现?谢谢
LZ是不是想做文本编辑器那种效果?可以选取任何一段文字呢???
love008 & &
& & (0)(0)richTextBox.Rtf=文本内容
tangyongjiang & &
& & (0)(0)private void button1_Click(object sender, EventArgs e)
richTextBox1.Text =
&Zswang 路过 &;
richTextBox1.SelectionStart = 5;
richTextBox1.SelectionLength = 2;
textBox1.Text = richTextBox1.SelectedR
} tangyss4 & &
& & (0)(0)
本问题标题:
本问题地址:
温馨提示:本问题已经关闭,不能解答。
暂无合适的专家
&&&&&&&&&&&&&&&
希赛网 版权所有 & &&&&湘教QS2-164&&增值电信业务经营许可证湘B2-C# richTextBox显示不同颜色文字
view plaincopy to clipboardPRint?#region 日志记录、支持其他线程访问&& &&&&&&& public delegate void LogAppendDelegate(Color color, string text);&& &&&&&&& /// &summary&&& &&&&&&& /// 追加显示文本&& &&&&&&& /// &/summary&&& &&&&&&& /// &param name="color"&文本颜色&/param&&& &&&&&&& /// &param name="text"&显示文本&/param&&& &&&&&&& public void LogAppend(Color color, string text)&& &&&&&&& {&& &&&&&&&&&&& richTextBoxRemote.AppendText("
");&& &&&&&&&&&&& richTextBoxRemote.SelectionColor =&& &&&&&&&&&&& richTextBoxRemote.AppendText(text);&& &&&&&&& }&& &&&&&&& /// &summary&&& &&&&&&& /// 显示错误日志&& &&&&&&& /// &/summary&&& &&&&&&& /// &param name="text"&&/param&&& &&&&&&& public void LogError(string text)&& &&&&&&& {&& &&&&&&&&&&& LogAppendDelegate la = new LogAppendDelegate(LogAppend);&& &&&&&&&&&&& richTextBoxRemote.Invoke(la, Color.Red, DateTime.Now.ToString("HH:mm:ss ") + text);&& &&&&&&& }&& &&&&&&& /// &summary&&& &&&&&&& /// 显示警告信息&& &&&&&&& /// &/summary&&& &&&&&&& /// &param name="text"&&/param&&& &&&&&&& public void LogWarning(string text)&& &&&&&&& {&& &&&&&&&&&&& LogAppendDelegate la = new LogAppendDelegate(LogAppend);&& &&&&&&&&&&& richTextBoxRemote.Invoke(la, Color.Violet, DateTime.Now.ToString("HH:mm:ss ") + text);&& &&&&&&& }&& &&&&&&& /// &summary&&& &&&&&&& /// 显示信息&& &&&&&&& /// &/summary&&& &&&&&&& /// &param name="text"&&/param&&& &&&&&&& public void LogMessage(string text)&& &&&&&&& {&& &&&&&&&&&&& LogAppendDelegate la = new LogAppendDelegate(LogAppend);&& &&&&&&&&&&& richTextBoxRemote.Invoke(la, Color.Black, DateTime.Now.ToString("HH:mm:ss ") + text);&& &&&&&&& }& &&&&&&& #endregion
您对本文章有什么意见或着疑问吗?请到您的关注和建议是我们前行的参考和动力&&
您的浏览器不支持嵌入式框架,或者当前配置为不显示嵌入式框架。}

我要回帖

更多关于 richtextbox换行 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信