Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 2nd, 2008, 03:19 AM
Authorized User
 
Join Date: Apr 2008
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default checkedListBox to a listbox?

Hallo,

How do I get my Items from my checkedListBox to a listbox?

I tryed here, but it do not work

listBox3.Items.AddRange(checkedListBox5.CheckedIte ms)

I got these errors:
Error 3 The best overloaded method match for 'System.Windows.Forms.ListBox.ObjectCollection.Add Range(System.Windows.Forms.ListBox.ObjectCollectio n)' has some invalid arguments
Error 4 Argument '1': cannot convert from 'method group' to 'System.Windows.Forms.ListBox.ObjectCollection'


Greetings
Silas
 
Old May 2nd, 2008, 03:40 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

It might seem long winded but why not just do:

foreach(object i in checkedListBox5.CheckedItems) listBox3.Items.Add(i);


/- Sam Judson : Wrox Technical Editor -/
 
Old May 2nd, 2008, 04:24 AM
Authorized User
 
Join Date: Apr 2008
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot.. But what do I do, if I want to add the objekts to a list

 List<string> temp_flasker_liste = new List<string>();

            foreach (object i in checkedListBox5.CheckedItems) temp_flasker_liste.Add(i);

I get these errors:
Error 1 The best overloaded method match for 'System.Collections.Generic.List<string>.Add(strin g)' has some invalid arguments
Error 2 Argument '1': cannot convert from 'object' to 'string'
 
Old May 2nd, 2008, 04:25 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

temp_flasker_liste.Add(i.ToString());

/- Sam Judson : Wrox Technical Editor -/
 
Old May 2nd, 2008, 04:31 AM
Authorized User
 
Join Date: Apr 2008
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks..






Similar Threads
Thread Thread Starter Forum Replies Last Post
multiple Listbox values in another listbox terryv Excel VBA 0 June 27th, 2007 07:01 AM
get current checkedlistbox value zachatcoza C# 0 June 8th, 2007 08:42 AM
CheckedListBox control and Database M3L C# 1 May 26th, 2004 11:50 PM
I'm back :) Listbox var from listbox MichaelTJ .NET Web Services 2 October 21st, 2003 07:06 PM
make checkedListBox readonly melvik C# 0 September 14th, 2003 09:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.