1

我想知道如何使用 RichTextbox 中的文本绘制字符串,我做到了,但是没有绘制像粗体、斜体和对齐这样的文本格式。

Private Sub PictureBox4_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox4.Paint
    Dim newImage As Image = Panel1.BackgroundImage
    Dim fontt As New Font("Tahoma", 10)
    Dim format As New StringFormat
    format.Alignment = StringAlignment.Far
    e.Graphics.DrawImage(newImage, 0, 0)
    e.Graphics.DrawString(RichTextBox1.Text, fontt, Brushes.Silver, 10, 10)
End Sub

我用来PictureBox4_Paint在表单加载时绘制字符串。请帮忙

谢谢 :)

4

1 回答 1

-1

您必须Font使用适当的来创建FontStyle,例如

Dim fontt As New Font("Tahoma", 10, FontStyle.Bold or FontStyle.Italic)

并且要使用StringFormat,您必须使用接受参数的重载:DrawStringStringFormat

e.Graphics.DrawString(RichTextBox1.Text, fontt, Brushes.Silver, 10, 10, format)
于 2013-09-24T09:16:09.750 回答