OpenNETCF ListBoxEx changes item fonts while adding the items

R

Roberto Rocco

Hello,

After you add a list item to the ListBoxEx the font of the item changes!

I need a ListBox where the items shall have different fonts.
Therefore I set the font of the items e.g. like this:

OpenNETCF.Windows.Forms.ListItem item = new
OpenNETCF.Windows.Forms.ListItem();
item.Font = new System.Drawing.Font ("Microsoft Sans Serif", 16.0F,
System.Drawing.FontStyle.Bold);
listBoxEx1.Items.Add (item); // Hey! My font has changed!!!

But after adding the list item to the ListBoxEx the font of the item I
previously set changes! (line 3 in the sample code above)

Of course I could set all the list item fonts AFTER adding the items to the
list, but this would be a rather tedious task, especially because I want to
have my own ListItem Class derived from OpenNETCF.Windows.Forms.ListItem and
I want to set the item font inside the constructor of this derived class as
this:

listBoxEx1.Items.Add(new MyListItem (MyFontSize);

Is there any special reason for this strange behaviour or is it a known bug
inside the ListBoxEx class?

Many thanks in advance,

Roberto Rocco.
 
G

Guest

If you'd take a look at the Add method of the ItemCollection class:

http://www.opennetcf.org/SourceBrow...t/Source/OpenNETCF.Windows.Forms/ListBoxEx.cs
(line 572 through 588)

you will see that the font for the ListItem is been assign from the parent's
value and the line if (value.Font == null) has been commented out. I don't
remember the exact reason, but I think I was having some problems with the
design time behaviour of the control. You can try to uncomment this line and
see if it fixes your problem.
 
R

Roberto Rocco

Hello Alex,

thank you for your fast reply!
I've never done a rebuild on OpenNETCF.Windows.Forms before and mybe I'm
doing something wrong here...

I can debug inside the OpenNETCF.Windows.Forms code, but executing the line
:
listBoxEx1.Items.Add (item);
I find myself inside OpenNETCF.Windows.Forms.ListBoxEx.cs at line 252 in the
method:
public Color EvenItemColor

I also set a breakpoint at the Add method of the ItemCollection class at
line 572, but it never gets reached when I call :
listBoxEx1.Items.Add (item);

It only gets reached once during program startup!

Any idea what might be wrong here?

Again, sorry, I'm an absolute beginner in debugging and modifying OpenNETCF
classes, so maybe I'm doing something terribly wrong...

Many thanks in advance,

Roberto Rocco.
 
G

Guest

It looks like you're trying to debug against an existing assembly. You should
go to the <VS Studio Path>\CompactFrameworkSDK\v1.0.5000\Windows CE driectory
and rename
OpenNETCF.Windows.Forms.dll assembly.
 
R

Roberto Rocco

Hello Alex,

yes, you were right! After I removed all the existing OpenNETCF references
from my project and added the "new" ones that I've built it worked.
And yes, removing the comments from the lines you mentioned solved the
problem of the missing fonts!

Do you see any chance having this "fix" incorporated in the next release of
the SDF 1.3? (Maybe together with a ListBoxEx version that supports the
TopIndex method?)

Again, many thanks for your support,

Roberto Rocco.
 
G

Guest

Do you see any chance having this "fix" incorporated in the next release of
the SDF 1.3? (Maybe together with a ListBoxEx version that supports the
TopIndex method?)

Yes, I'll try to make it happen.

Thanks... Alex
 

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