Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / October 2004

Tip: Looking for answers? Try searching our database.

listbox frenzy

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rodchar - 25 Sep 2004 06:53 GMT
Hey all,

I was wondering if you databind to a listbox, can you at the same time have
an extra item in there like say, <new> ?

thanks,
rodchar
Lucas Tam - 25 Sep 2004 07:52 GMT
> I was wondering if you databind to a listbox, can you at the same time
> have an extra item in there like say, <new> ?

Yes. Just add the item AFTER the databind.

Signature

Lucas Tam (REMOVEnntp@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/

rodchar - 25 Sep 2004 08:59 GMT
Hey Lucas,

when I add it like this, I get an error message.
       lbDescription.DataSource = _dt
       lbDescription.DisplayMember = "Description"
       lbDescription.ValueMember = "CodesID"
       lbDescription.Items.Add("<New>")

I get this error:
An unhandled exception of type 'System.ArgumentException' occurred in
system.windows.forms.dll

Additional information: Cannot modify the Items collection when the
DataSource property is set.

> > I was wondering if you databind to a listbox, can you at the same time
> > have an extra item in there like say, <new> ?
>
> Yes. Just add the item AFTER the databind.
Lucas Tam - 25 Sep 2004 16:13 GMT
> I get this error:
> An unhandled exception of type 'System.ArgumentException' occurred in
> system.windows.forms.dll
>
> Additional information: Cannot modify the Items collection when the
> DataSource property is set.

Hmm, it works with Webforms, I guess I never tried it with Winforms.

Try adding the item to the dataset ... then binding it. That should work
for sure.

Signature

Lucas Tam (REMOVEnntp@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/

Ken Tucker [MVP] - 25 Sep 2004 09:56 GMT
Hi,

       You have to add the item to the datasource.

Ken
-----------------
Hey all,

I was wondering if you databind to a listbox, can you at the same time have
an extra item in there like say, <new> ?

thanks,
rodchar
rodchar - 25 Sep 2004 18:43 GMT
10-4.

> Hi,
>
[quoted text clipped - 9 lines]
> thanks,
> rodchar
VitorJOL - 27 Oct 2004 20:07 GMT
Hello

I have the same problem...but i want to remove a item from listbox but not
remove it from db. the error its the same!!! I can i do this ???

Sorry but i dont understand the other answers to the problem of Rodchar

VitorJOL

> 10-4.
>
[quoted text clipped - 11 lines]
> > thanks,
> > rodchar

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.