473,387 Members | 1,486 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

My ComboBoxEx is not working

Hello

I'm writing an enhanced version of ComboBox (that inherits from
Windows.Forms.ComboBox) that can display images close to the text.
I've replaced the default Item collection (ComboBox.ObjectCollection, that
is a collecion of Object objects) with my own collection
(ImageComboBoxItemCollection) that holds a number of custom
ImageComboBoxItem items that inherits from Object.

Editor(GetType(ImageComboItemCollectionEditor), GetType(UITypeEditor))> _
Public Shadows ReadOnly Property Items() As ImageComboItemCollection

Everything works fine (serialization included), except for the Overrides of
OnDrawItem that does NOT works. Debugging the ComboBoxEx, I've noted that
OnDrawItem is never called.
If I try to suppress the Shadowing of Items Property, everithing is working
fine again, and OnDrawItem is properly called again.

What's wrong?

Thank you.

Carlo

-------------------------------------------
Carlo, MCP (Windows Based Applications)
ca************@gmail.com

Nov 23 '05 #1
6 1533
Does the example on my site help you out at all?
http://www.dotnetrix.co.uk/combobox.html

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Carlo" <ca************@gmail.com> wrote in message
news:Oa**************@TK2MSFTNGP09.phx.gbl...
Hello

I'm writing an enhanced version of ComboBox (that inherits from
Windows.Forms.ComboBox) that can display images close to the text.
I've replaced the default Item collection (ComboBox.ObjectCollection, that
is a collecion of Object objects) with my own collection
(ImageComboBoxItemCollection) that holds a number of custom
ImageComboBoxItem items that inherits from Object.

Editor(GetType(ImageComboItemCollectionEditor), GetType(UITypeEditor))> _
Public Shadows ReadOnly Property Items() As ImageComboItemCollection

Everything works fine (serialization included), except for the Overrides
of OnDrawItem that does NOT works. Debugging the ComboBoxEx, I've noted
that OnDrawItem is never called.
If I try to suppress the Shadowing of Items Property, everithing is
working fine again, and OnDrawItem is properly called again.

What's wrong?

Thank you.

Carlo

-------------------------------------------
Carlo, MCP (Windows Based Applications)
ca************@gmail.com

Nov 23 '05 #2
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)
ca************@gmail.com
"Mick Doherty"
<EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]> ha
scritto nel messaggio news:uV****************@TK2MSFTNGP12.phx.gbl...
Does the example on my site help you out at all?
http://www.dotnetrix.co.uk/combobox.html

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Carlo" <ca************@gmail.com> wrote in message
news:Oa**************@TK2MSFTNGP09.phx.gbl...
Hello

I'm writing an enhanced version of ComboBox (that inherits from
Windows.Forms.ComboBox) that can display images close to the text.
I've replaced the default Item collection (ComboBox.ObjectCollection,
that is a collecion of Object objects) with my own collection
(ImageComboBoxItemCollection) that holds a number of custom
ImageComboBoxItem items that inherits from Object.

Editor(GetType(ImageComboItemCollectionEditor), GetType(UITypeEditor))> _
Public Shadows ReadOnly Property Items() As ImageComboItemCollection

Everything works fine (serialization included), except for the Overrides
of OnDrawItem that does NOT works. Debugging the ComboBoxEx, I've noted
that OnDrawItem is never called.
If I try to suppress the Shadowing of Items Property, everithing is
working fine again, and OnDrawItem is properly called again.

What's wrong?

Thank you.

Carlo

-------------------------------------------
Carlo, MCP (Windows Based Applications)
ca************@gmail.com


Nov 23 '05 #3
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.

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Carlo" <ca************@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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)
ca************@gmail.com

Nov 23 '05 #4
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)
ca************@gmail.com
"Mick Doherty"
<EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]> ha
scritto nel messaggio news:eJ**************@TK2MSFTNGP14.phx.gbl...
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.

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Carlo" <ca************@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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)
ca************@gmail.com


Nov 23 '05 #5
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

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Carlo" <ca************@gmail.com> wrote in message
news:ey**************@tk2msftngp13.phx.gbl...
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)
ca************@gmail.com

Nov 23 '05 #6
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)
ca************@gmail.com
"Mick Doherty"
<EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]> ha
scritto nel messaggio news:%2****************@TK2MSFTNGP14.phx.gbl...
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

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Carlo" <ca************@gmail.com> wrote in message
news:ey**************@tk2msftngp13.phx.gbl...
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)
ca************@gmail.com


Nov 24 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Gary | last post by:
I am trying to use the "System.Windows.Forms.SendKeys" class for triggering the Ctrl+P key. Syntax: System.Windows.Forms.SendKeys.Send("^(P)"); This is not working ..what could be the...
0
by: mnsindhu74 | last post by:
How to use - ComboBoxEx Control in c#. I want to create a new combobox control which can display icons in the listBox as well as the editbox. I am using dropdown style. Making the combox ownerdraw...
6
by: Mullin Yu | last post by:
hi, i have a web service that has file operations on Windows OS, and there may be a file concurrency issue if only one working directory e.g. c:\working therefore, i want to have a unique sub...
3
by: | last post by:
Hello, I am hoping someone else has thought about a date time calculation i need to perform. I would like to be able to calculate the number of "working minutes" between 2 dates, given my...
5
by: Martin Heuckeroth | last post by:
Hi We are working on a webservice application and are having some problems with the cookies and/or sessions. We have them working on our intranet but then its not working on the internet. We...
5
by: tshad | last post by:
I have been working with setting my drop boxes to allow double clicking to select an item. It worked fine until I made some changes. I then stripped the page down to the bare essentials to find...
8
by: jojobar | last post by:
Okay, I am trying to do is to test the webresource in 2.0 1. I created a new project with assembly name (and default assembly name) "Office". 2. I added the following to the AssemblyInfo.cs...
2
by: Don | last post by:
I'm having problems with intellisense, autocomplete, etc. suddenly not working in certain classes of a project I'm working on. All the options are set, and it all works fine for most classes, but...
9
by: MSDNAndi | last post by:
Hi, I have a set of simple webservices calls that worked fine using .NET Framework 1.0. I am calling a Java/Apache based webservices, the calling side is not able to supply a proper WSDL. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.