Richtextbox控件设置字体颜色? ------在线等待!!

herotiger823 herotiger823 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我得代码:
Private Sub Command1_Click() //选择颜色
'将 Cancel 设置成 True。
CommonDialog1.CancelError = True
On Error GoTo ErrHandler
'设置 Flags 属性。
CommonDialog1.Flags = cdlCCRGBInit
'显示“颜色”对话框。
CommonDialog1.ShowColor
'将文本筐的背景颜色设置成选定的'颜色。
Me.Text1.ForeColor = CommonDialog1.Color
Exit Sub

ErrHandler:
'用户按了“取消”按钮。
Exit Sub
End Sub

Private Sub Command2_Click() //将文本筐内的文本发送到Richtextbox里
strStart1 = Len(Text1.Text)
strStart2 = Len(RichTextBox1.Text)
With RichTextBox1
.Text = .Text & Text1.Text & vbCrLf
.SelStart = strStart2
.SelLength = strStart1
.SelColor = Me.Text1.ForeColor
End With
End Sub

问题是前两次设置颜色成功,到第三次以后前面的文本颜色就变成了默认色了!
...全文
评论 7
收藏 已收藏
分享
返回顶部
herotiger823
控件 1,453 成员 41,351 内容