2011-04-27 30 views
0

我已經問過一個非常類似的問題,但這次不是關於VB語法,而是最好的方法。我做了一個方法,當傳遞一個組件時,它會重新着色它和其中包含的所有組件。下面是我到目前爲止的代碼,但它不是重新着色所有組件,而只是少數。我的主要問題是按鈕保持「3D」風格,而不是「平坦」。在VB中選擇性遞歸組件重新着色

If TypeOf comp Is System.Windows.Forms.ButtonBase Then 
     Dim c As System.Windows.Forms.ButtonBase 
     c = comp 
     c.FlatStyle = Windows.Forms.FlatStyle.Flat 
     c.BackColor = getColor(style, PART_BOX) 
     c.ForeColor = getColor(style, PART_TEXT) 

     comp = c 
    End If 

傳遞的組分是comp,並且getColor方法看起來到數據庫中並返回對應於傳遞給該方法的part參數的顏色。這適用於所有底層組件和標籤等所有簡單組件。

This is what happens. As you can see, the colors are fetched and applied properly to many components, but not all.

正如你所看到的,這不是我的首選的結果。 有誰知道如何重新着色旋鈕,按鈕和菜單欄?同樣,我需要的按鈕最終是平板

回答