2013-03-21 86 views
1

我想在Visual Studio 2012中創建vb.net中的自定義屬性,但我有設置我的自定義屬性設計時間和運行時間的問題。這不是Visual Studio 2010的問題。它看起來像一個錯誤,但也許我忘了打開或關閉一些選項,或者忘記了我的代碼中的某些內容?自定義屬性視覺工作室2012

Public Class MyCustomButton 
    Inherits Button 

    Private m_MyBackgroundColor As Color 
    Public Property MyBackgroundColor As Color 
    Get 
     Return m_MyBackgroundColor 
    End Get 
    Set(value As Color) 
     value = m_MyBackgroundColor 
     Me.BackColor = m_MyBackgroundColor 
    End Set 
    End Property 
End Class 
+0

你的二傳手似乎是錯誤的。您正在用您的字段的當前值覆蓋'value'參數,而不是反之。 – 2013-03-22 00:06:08

回答

0

變化二傳手這樣:

Set(value As Color) 
    m_MyBackgroundColor = value 'swapped value and m_MyBackgroundColor 
    Me.BackColor = m_MyBackgroundColor 
End Set 
+0

很多深夜!答案很簡單: 將value = m_MyBackgroundColor更改爲 m_MyBackgroundColor = value解決了問題。 – TinTin 2013-03-21 21:42:07

+0

@ user2196583:我想我也需要一些睡眠,因爲直到現在我才注意到這個問題。恭喜你自己找到它。 :) – Neolisk 2013-03-21 22:05:18

+1

感謝您的幫助Neolisk – TinTin 2013-03-21 23:24:45