For Programmers: Free Programming Magazines  


Home > Archive > VB Controls Databound > January 2005 > Re: PROBLEM:"Cannot modify the Items collection when the DataSource...









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: PROBLEM:"Cannot modify the Items collection when the DataSource...
Nico

2005-01-23, 9:01 pm

You can always try to do it manually:
you don't set the datasource to the listbox. Here is how i did it:
I used a Recordset and a for loop.
Something like this:
For intcounter=0 to rstRecordset.RecordCount
lstListbox.AddItem rstRecordset.Fields("NameField"), intcounter
Next
If you afterwards need to refresh the listbox, don't forget to empty it
first:
For intcounter=rstRecordset.RecordCount to 0 Step -1
lstListbox.RemoveItem intcounter
Next
If you have any more questions, don't hesitate to ask them.
Regards,
Nico.

"VitorJOL" <VitorJOL@discussions.microsoft.com> schreef in bericht
news:4CE4D0CE-0963-4021-95E3-CD23812AB785@microsoft.com...
> Hello
> I have a listbox with a datasource.I want to remove a row from listbox but
> not remove it from the database.
> How can i do this ?
>
> PROBLEM:"Cannot modify the Items collection when the DataSource property
> is
> set."



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com