2017-04-08 49 views
0
Private Sub btnReset_Click(sender As Object, e As EventArgs) Handles btnReset.Click 

    txtRate.Text = "0" 
    lblPromotional.ForeColor = Color.Empty 
    lblPromotional.BackColor = Color.Empty 
    lblPromotional.Font = originalfontname() 

它不適用於字體?如何在vb.net中單擊按鈕時將字體重置爲原始文件?

+0

'originalfontname()'做了什麼? – Dai

+0

我不知道那...我用它作爲隨機 –

回答

0

您需要先緩存整個Font對象,然後再對其進行更改 - 而不僅僅是字體名稱。

Class SomeForm Inherits Form 

    Private originalFont As Font 

    Sub Form_Load(sender As Object, e As EventArgs) Handles Me.Load 
     Me.originalFont = Me.lblPromotional.Font 
    End Sub 

    Private Sub btnReset_Click(sender As Object, e As EventArgs) Handles btnReset.Click 

     txtRate.Text = "0" 
     lblPromotional.ForeColor = Color.Empty 
     lblPromotional.BackColor = Color.Empty 
     lblPromotional.Font = Me.originalFont 
    End Sub 

End Class 
+0

戴先生可以讓我任何其他代碼相同的backcolor和fontcolor使用...我不想做一個子例程...請 –

相關問題