更改richtextbox的颜色! [英] Changing a richtextbox's colour!
问题描述
编译好了。
我将RTB的前后颜色保存到注册表中,如
这个:
Srx.SetValue(" ForeColour",Console.ForeColor.ToArgb.ToString)
Srx.SetValue(" BackColour",Console.BackColor.ToArgb .ToString)
然后,我尝试在运行时读回颜色并更改RTB的
颜色,如下所示:
Dim ForeCol As New System.Drawing.Color
Dim BackCol As New System.Drawing.Color
ForeCol.FromName(Lrx .GetValue(ForeColour))
Console.ForeColor = ForeCol
BackCol.FromName(Lrx.GetValue(" BackColour"))
Console.BackColor = BackCol
颜色保存到注册表确定但是当表单加载时它是
不改变颜色!据我所知,值已被读取
从注册表返回OK但是被忽略了。
任何想法?谢谢。
你好,
Srx.SetValue(" ForeColour" ,Console.ForeColor.ToArgb.ToString)
Srx.SetValue(" BackColour",Console.BackColor.ToArgb.ToString)
看起来你保存到Argb价值在这里...
Dim ForeCol As New System.Drawing.Color
Dim BackCol As New System.Drawing.Color
ForeCol.FromName(Lrx.GetValue (ForeColour))
Console.ForeColor = ForeCol
BackCol.FromName(Lrx.GetValue(" BackColour"))
Console.BackColor = BackCol>
但是从这里的名字加载。请改用FromArgb。
我希望这会有所帮助。
尼克。
>但是从这里的名称加载。请改用FromArgb。
我希望这会有所帮助。
尼克。
谢谢,我从未见过。我已经更改了它,但它没有
的区别。加载的颜色仍然是白色的黑色文字
背景。
Hugh
Hugh Janus <我的************* @ hotmail.com> schrieb:我将RTB的前后颜色保存到注册表中,如
这个:
Srx.SetValue(" ForeColour",Console。 ForeColor.ToArgb.ToString)
Srx.SetValue(" BackColour",Console.BackColor.ToArgb.ToString)
然后,我尝试在运行时读回颜色并更改
RTB的颜色如下:
Dim ForeCol As New System.Drawing.Color
Dim BackCol As New System.Drawing.Color
ForeCol .FromName(Lrx.GetValue(" ForeColour"))
\\\
Me.RichTextBox1.BackColor = _
Color.FromName(CInt(Lrx.GetValue(" ForeColor))))
///
-
MS Herfried K. Wagner
MVP< URL:http://dotnet.mvps.org/>
VB< URL :http://classicvb.org/petition/>
OK, this is driving me crazy! As far as I can tell it should work. It
compiles fine.
I am saving the fore and back colour of a RTB to the registry like
this:
Srx.SetValue("ForeColour", Console.ForeColor.ToArgb.ToString)
Srx.SetValue("BackColour", Console.BackColor.ToArgb.ToString)
Then, I try to read the colours back in at runtime and change the
colour of the RTB like this:
Dim ForeCol As New System.Drawing.Color
Dim BackCol As New System.Drawing.Color
ForeCol.FromName(Lrx.GetValue("ForeColour"))
Console.ForeColor = ForeCol
BackCol.FromName(Lrx.GetValue("BackColour"))
Console.BackColor = BackCol
The colours get saved to the registry OK but when the form loads it is
not changing the colours! As far as I can tell the values are read
back from the registry OK but just ignored.
Any ideas?? Thanks.
Hi Hugh,
Srx.SetValue("ForeColour", Console.ForeColor.ToArgb.ToString)
Srx.SetValue("BackColour", Console.BackColor.ToArgb.ToString)
It looks like your saving to an Argb value here...
Dim ForeCol As New System.Drawing.Color
Dim BackCol As New System.Drawing.Color
ForeCol.FromName(Lrx.GetValue("ForeColour"))
Console.ForeColor = ForeCol
BackCol.FromName(Lrx.GetValue("BackColour"))
Console.BackColor = BackCol
But loading from a Name here. Use FromArgb instead.
I hope this helps.
Nick.
>But loading from a Name here. Use FromArgb instead.
I hope this helps.
Nick.
Thanks, I never saw that. I have changed it but it makes no
difference. The colours loaded are still black text on white
background.
Hugh
"Hugh Janus" <my*************@hotmail.com> schrieb:I am saving the fore and back colour of a RTB to the registry like
this:
Srx.SetValue("ForeColour", Console.ForeColor.ToArgb.ToString)
Srx.SetValue("BackColour", Console.BackColor.ToArgb.ToString)
Then, I try to read the colours back in at runtime and change the
colour of the RTB like this:
Dim ForeCol As New System.Drawing.Color
Dim BackCol As New System.Drawing.Color
ForeCol.FromName(Lrx.GetValue("ForeColour"))
\\\
Me.RichTextBox1.BackColor = _
Color.FromName(CInt(Lrx.GetValue("ForeColor")))
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
这篇关于更改richtextbox的颜色!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!