vb.net 中的 VB6.FontChangeName 替代方案是什么

what is the VB6.FontChangeName alternative in vb.net

我已使用向导工具将 VB6 迁移到 VB.Net,下面是正在迁移的 属性 之一。 sprSpread 是 far pint 点差控制参考。

Public Property FontName() As String
    Get
        FontName = sprSpread.Font.Name
    End Get
    Set(ByVal Value As String)
        sprSpread.Font = VB6.FontChangeName(sprSpread.Font, Value)
        RaiseEvent FontNameChange()
    End Set
End Property 

Vb.Net VB6.FontChangeName

的替代方案是什么

由于 Font class 的属性是只读的,当你需要在 .NET 中更改字体的 属性 时,你需要创建一个全新的Font 对象。例如:

' Create a new font with the same size and style as before, but with a different name
sprSpread.Font = New Font(Value, sprSpread.Font.Size, sprSpread.Font.Style)