简体   繁体   English

Visual Basic中MsgBox的粗体字体

[英]Bold font for MsgBox in Visual Basic

How to make font bold in a MessageBox in Visual Basic 2008? 如何在Visual Basic 2008中的MessageBox中使字体变粗?

I would like to have it like this: 我想这样:

MsgBox(Documentation: .........) 

where "Documentation" will be showing in a bold font. 其中“文档”将以粗体显示。

As aphoria said, VB's MsgBox does not allow bold text. 正如aphoria所说,VB的MsgBox不允许使用粗体文本。 Here is how you work around that: 以下是您解决这个问题的方法:

1) Add a "New Windows Form" 2) Add a RichTextBox 3) Add the # of CommandButtons you want/need 4) Go to the code for the form and do something like the following 1)添加“新Windows窗体”2)添加RichTextBox 3)添加您想要/需要的CommandButtons 4)转到窗体的代码并执行以下操作

Public Sub CustomMessageBox(ByVal msg As String, ByVal isBold As Boolean, ByVal color As System.Drawing.Color, ByVal buttonOneText As String, ByVal buttonTwoText As String, ByVal startBoldAt As Integer = 0, ByVal endBoldAt As Integer = 0)
 ' Use parameters to pass the values you want to show
 ' startBoldAt will be the position in the string where you want to have bold lettering begin, and endBoldAt will be the position in the string where you want bold lettering to end.
End Sub

Then you can do:  
Dim cmb as CustomMessageBox = New CustomMessageBox('Your parameters)
' Add a sub that will let you show the CustomMessageBox
cmb.Show()

Hope that helps. 希望有所帮助。

The built-in MsgBox function cannot do this. 内置的MsgBox函数无法执行此操作。 You will have to build your own if you really need it. 如果你真的需要它,你将不得不建立自己的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM