gpt4 book ai didi

.net - 如何在 VB.NET.. 中为字体类对象设置颜色?

转载 作者:行者123 更新时间:2023-12-04 06:45:27 25 4
gpt4 key购买 nike

如何在 VB.NET.. 中为字体类对象设置颜色?
我的意思是..

   Dim MYfONT As New Font("Microsoft Sans Serif", 16, FontStyle.Bold)
e.Graphics.DrawString(TabMain.TabPages(e.Index).Text, MYfONT, SystemBrushes.HighlightText, paddedBounds)

如何将此字体类对象(MYfONT)-颜色设置为黑色。 ?

最佳答案

只需扩展您的 SystemBrushes.HighlightTextNew SolidBrush(Color.Black)

Public Sub DrawStringRectangleF(ByVal e As PaintEventArgs)    
' Create string to draw.'
Dim drawString As [String] = "Sample Text"

' Create font and brush.'
Dim drawFont As New Font("Arial", 16)
Dim drawBrush As New SolidBrush(Color.Black)

' Create rectangle for drawing.'
Dim x As Single = 150.0F
Dim y As Single = 150.0F
Dim width As Single = 200.0F
Dim height As Single = 50.0F
Dim drawRect As New RectangleF(x, y, width, height)

' Draw rectangle to screen.'
Dim blackPen As New Pen(Color.Black)
e.Graphics.DrawRectangle(blackPen, x, y, width, height)

' Draw string to screen.'
e.Graphics.DrawString(drawString, drawFont, drawBrush, drawRect)
End Sub

Reference

关于.net - 如何在 VB.NET.. 中为字体类对象设置颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3792469/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com