我试图通过使用递归方法重新着色一个窗体中的所有组件。然而,它总是重新记录表格,然后停下来。我怎样才能让它走过这一步?这里是我一直在试验的代码:在VB中递归重新着色
Public Sub fixUIIn(ByRef comp As System.ComponentModel.Component, ByVal style As SByte)
Debug.WriteLine(comp)
If TypeOf comp Is System.Windows.Forms.ContainerControl Then
Dim c As System.Windows.Forms.ContainerControl
c = comp
c.BackColor = getColor(style, PART_BACK)
c.ForeColor = getColor(style, PART_TEXT)
If ((comp.Container IsNot Nothing) AndAlso (comp.Container.Components IsNot Nothing)) Then
For i As Integer = 0 To comp.Container.Components.Count() Step 1
fixUIIn(comp.Container.Components.Item(i), style)
Next
End If
comp = c
End If
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
If ((comp.Container IsNot Nothing) AndAlso (comp.Container.Components IsNot Nothing)) Then
For i As Integer = 0 To comp.Container.Components.Count() Step 1
fixUIIn(comp.Container.Components.Item(i), style)
Next
End If
End Sub
你运行这一点,以便补偿=当前的形式?尝试在窗体上的控件上运行它。 – Toby 2011-04-07 20:18:09
是的,是怎么回事? – Supuhstar 2011-04-08 19:23:23