At a first look, the answer is 'yes'. I'll study the sample in depth.
The only difference I noted is that you used
Public Shadows ReadOnly Property Items() As ObjectCollection
while I used
Public Shadows ReadOnly Property Items() As ImageComboItemCollection
Do you think that the different type of the collection can be responsible
for the problem I have?
Thany you, Mick, for helping me...
Carlo
-------------------------------------------
Carlo, MCP (Windows Based Applications)
carlodevREMOVE@gmail.com
There are two main differences.
The first, as you pointed out, is the collection type. I never managed to
get this working with a custom collection, even when it was inherited from
ObjectCollection, but to be quite honest, I didn't really try too hard as I
believe the simple solutions are often the best.
The second difference is that my custom item is inherited from Component
rather than Object. Inheriting from Object will probably work, but requires
much more work to get the class to Serialize.

Signature
Mick Doherty
http://dotnetrix.co.uk/nothing.html
> At a first look, the answer is 'yes'. I'll study the sample in depth.
>
[quoted text clipped - 13 lines]
> Carlo, MCP (Windows Based Applications)
> carlodevREMOVE@gmail.com
Carlo - 23 Nov 2005 08:31 GMT
Good morning Mick
in my previous version, I inherited from Object (and serialization works),
but inheriting from Component is much more useful. For example, the built-in
(name) property does not exist in Object.
However, now I'm trying to "inject" some of your ideas into my version. My
goal is to get a quite more complex Items collection (with ImageIndex,
Image, Tag, Text, ForeColor, etc.).
Is thee only a bit of code that I've not understood.
This is my version:
Public Property Text() As String
Get
Return mText
End Get
Set(ByVal Value As String)
mText = Value
End Set
End Property
Public Overrides Function ToString() As String
Return Text
End Function
...and this is your:
Public Property Item() As Object
Get
Return mObject
End Get
Set(ByVal Value As Object)
mObject = Value
End Set
End Property
Public Overrides Function ToString() As String
If mObject Is Nothing Then
Return String.Empty
Else
Return mObject.ToString
End If
End Function
I've not understood the purpose of the Item property. Is is required by the
ObjectCollection to work properly? Do you think can be removed and replaced
with Text?
Thank you once more.
Carlo
-------------------------------------------
Carlo, MCP (Windows Based Applications)
carlodevREMOVE@gmail.com
> There are two main differences.
>
[quoted text clipped - 24 lines]
>> Carlo, MCP (Windows Based Applications)
>> carlodevREMOVE@gmail.com
Mick Doherty - 23 Nov 2005 11:34 GMT
Hi Carlo,
In a standard ComboBox the Item property is declared as Object. At
DesignTime you can only edit the collection to add Strings as the
CollectionEditor is defined as the StringCollection type. At Runtime though,
you can assign any type of Object to the Items collection (such as our
ImageComboItem type) and the DropDown list will display it's ToString value.
To see this in action just change the DrawMode property back to Normal and
you will see that the ComboBox will display the ImageComboItem.ToString()
value for each item.
If you have no intention of assigning complex types to the ImageCombo then
you can safely do away with it and assign the Text property as you've
defined it.
I should also point out a small bug which I have just found. The
SelectedIndexChanged event fires twice and so the OnSelectedIndexChanged()
code should be modified as follows:
Protected Overrides Sub OnSelectedIndexChanged(ByVal e As System.EventArgs)
If Me.SelectedIndex <> currentIndex Then
currentIndex = Me.SelectedIndex
MyBase.RefreshItem(Me.SelectedIndex)
Else
MyBase.OnSelectedIndexChanged(e)
End If
End Sub

Signature
Mick Doherty
http://dotnetrix.co.uk/nothing.html
> Good morning Mick
>
[quoted text clipped - 52 lines]
> Carlo, MCP (Windows Based Applications)
> carlodevREMOVE@gmail.com
Carlo - 24 Nov 2005 07:56 GMT
Hello Mick
I need to thank you very much for your valuable help.
Hope to meet you soon in ng!
Sincerely,
Carlo
-------------------------------------------
Carlo, MCP (Windows Based Applications)
carlodevREMOVE@gmail.com
> Hi Carlo,
>
[quoted text clipped - 81 lines]
>> Carlo, MCP (Windows Based Applications)
>> carlodevREMOVE@gmail.com