Private Sub Command1_Click()
' 设置“取消”为 True
CommonDialog1.CancelError = True
On Error GoTo ErrHandler
' 设置 Flags 属性
CommonDialog1.Flags = cdlCFEffects Or cdlCFBoth
' 显示“字体”对话框
CommonDialog1.ShowFont
RichTextBox1.Font.Name = CommonDialog1.FontName
RichTextBox1.Font.Size = CommonDialog1.FontSize
RichTextBox1.Font.Bold = CommonDialog1.FontBold
RichTextBox1.Font.Italic = CommonDialog1.FontItalic
RichTextBox1.Font.Underline = CommonDialog1.FontUnderline
Exit Sub
ErrHandler:
' 用户按了“取消”按钮
Exit Sub
End Sub
设置RICHTEXTBOX对应的字体格式属性为COMMONDIALOG返回的对应字体格式属性。
richtextbox1.font=commondialog1.font
a