I just wanted to use a listbox

I just wanted to use a listbox. How hard could that be? Harder than I thought:

I’ve recently decided to try my hand at writing programs for Windows Mobile Smartphones. I had an idea for a program and wanted to see if I could use the Compact Framework 2.0 and get it to work.

One of the main components of my program is a list. So, not surprisingly, I wanted to use a listbox. But it turns out that the version of the Compact Framework for Smartphones doesn’t have a listbox control.

So, I figured: “Oh well, I’ll just have to use a listview control set to List mode.”

(I first met listview controls in VB 6; didn’t like ‘em then and I’m still not too fond of ‘em now. I guess I never cared for the way they handle multicolumn lists – I found subitems to be a pain. But for this project I just needed a single column list.)

Now, in regular .Net a listbox control can hold objects -- as long as the objects implement a .ToString() method. The listbox uses this method to determine what to display in the list. This is exactly what I needed. Unfortunately, listview controls don’t just hold any arbitrary object. Instead they hold listviewitem objects.

So, I tried creating a new object that was derived from a listviewitem object. I planned on adding methods and properties to support my needs. I overrode the .ToString() method and found that listviewitems don’t use .ToString() to determine what text to display in the listview. Instead they have a .Text property. No, problem. I’ll just override the .Text property. Guess what? Listviewitem’s .Text property isn’t overridable!!!

Aaaarrrrrggggghhhhhhh!!!!!!!!!!

Comments

Popular posts from this blog

Restoring Color Icons in Gimp 2.10

PowerBuilder and SQL Server: Tips On Working Together

A tip on multithreading in PowerBuilder