编写组件类的 sub new的问题
Public Class ColorPickComboBox
Inherits System.Windows.Forms.ComboBox
Public Sub New()
MyBase.New()
Call FormatComboBoxColorList()
Me.Refresh()
End Sub
Private Sub FormatComboBoxColorList()
Dim i As Integer
Dim iColor As System.Drawing.Color
Me.Items.Clear()
For i = 1 To 100
Me.Items.Add(Str(i))
Next
End Sub
End Class
也就是继承类来编写组件,我就是想在subnew 过程中,自动向ComboBox增加100个item
但是在FormatComboBoxColorList过程中Me.Items.Clear()语句的作用就是清空项目在加入
但是有个问题,如果在该过程中添加debug.print me.items.count 在运行的时候会弹出100,并且
是两次,但运行后item确有200个,也就是FormatComboBoxColorList过程运行两次,每次运行都提示
加入100个项目,但最后确有200个