Overriding Control Properties (e.g. Combobox Items.Add)

H

HKSHK

Hi guys,

I'm currently trying to implement the VB6-ItemsData property into a
CombolBox and it works so far, but there is one problem...

I can only inherit one class to another class, which is either
a) System.Windows.Forms.ComboBox or
b) System.Windows.Forms.ComboBox.ObjectCollection.

If I add (a) I can't override Items.Add.
If I add (b) I would have to write a Sub New with MyBase.New or
MyClass.New and I don't know how to add new items to the list (since I
override the Add function). What can I do?

Thanks in advance for your help!

Please find my code below.

Best Regards,

HKSHK

Public Class ComboBoxVB6
Inherits System.Windows.Forms.ComboBox
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox

Public ItemData() As Integer

Public Sub AddItem(ByVal value As Object)
Me.Items.Add(value)
ReDim Preserve ItemData(Me.Items.Count)
End Sub

Private Sub InitializeComponent()
Me.ComboBox1 = New System.Windows.Forms.ComboBox()
Me.ComboBox1.Location = New System.Drawing.Point(17, 17)
Me.ComboBox1.Name = "ComboBoxVB6_"
Me.ComboBox1.TabIndex = 0
Me.ComboBox1.Text = "ComboBoxVB6_"

End Sub
End Class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top