Adding / removing items from OwnerDrawnList

  • Thread starter Thread starter Daan
  • Start date Start date
D

Daan

I have downloaded the code from the article by Alex Yakhnin from
<http://www.opennetcf.org/permalink2.aspx?guid=d88b1a1a-a866-4247-
a0c8-94ab3c124f63>. This runs just fine, however, when I want to add
or remove items from the list, things go wrong.

Adding items only works if I code it like this:

custListBox.Items.Insert(0, listItem);

What I actually want is to clear the entire list, load new items into
it and have the control update / repaint / etc. itself. However, when
I try that using the following code, a ArgumentOutOfRangeException
occurs when the control is repaining itself (as if it tries to paint
the no-longer-existing items...)

custListBox.Items.Clear();
custListBox.Items.Add(newItem1);
custListBox.Items.Add(newItem2);
// custListBox.Refresh();

Any suggestions or alternative solutions to creating such a list?
Thanks,
Daan
 
Hi Daan,

I believe the code you got from that article is rather incomplete. I suggest
downloading the source code for the Smart Device Framework 1.4. There would
be a control called ListBoxEx and SmartList (Smartphone enhanced I believe)
that inherits from a more complete OwnerDrawnList base control.
 
I believe the code you got from that article is rather incomplete. I suggest
downloading the source code for the Smart Device Framework 1.4. There would
be a control called ListBoxEx and SmartList (Smartphone enhanced I believe)
that inherits from a more complete OwnerDrawnList base control.

Thanks, that looks very useful! Now let
 
Hi Daan,

I believe the code you got from that article is rather incomplete. I suggest
downloading the source code for the Smart Device Framework 1.4. There would
be a control called ListBoxEx and SmartList (Smartphone enhanced I believe)
that inherits from a more complete OwnerDrawnList base control.

Thanks, that looks like a good solution! Now lets see if I can get
those ListItems to behave the way I want.
Regards,
Daan
 
Back
Top