Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 25th, 2008, 04:31 AM
Authorized User
Join Date: Apr 2008
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default problems with Arraylist of DateTime


I've got problems to adding the Items of my list of DateTime objects

I've got these error messages:

Error 4 The best overloaded method match for 'System.Windows.Forms.ListBox.ObjectCollection.Add Range(System.Windows.Forms.ListBox.ObjectCollectio n)' has some invalid arguments
Error 5 Argument '1': cannot convert from 'System.DateTime[]' to 'System.Windows.Forms.ListBox.ObjectCollection'

from the class:
public DateTime[] datoer_GetAllDatoSublist()
                return sublistNavne.ToArray();

From the windows form:
 private void button8_Click(object sender, EventArgs e)
            Reservering r1 = new Reservering("silas", new DateTime(2008, 04, 22));
            Reservering r2 = new Reservering("kurt", new DateTime(2008, 04, 23));
            Reservering r3 = new Reservering("Peter", new DateTime(2008, 04, 24));
            Flaske f1 = new Flaske(r1, "ok", 43);


          //this is the problem. AddRange
            listBox2.Items.AddRange(f1.datoer_GetAllDatoSublis t());


this is the list
  public List<DateTime> sublistNavne = new List<DateTime>();

            public DateTime[] datoer_makeDatoSublist(string navn)
               foreach (Reservering en_reservering in reserveringsliste)

                   if (en_reservering.PropertyReserveringsnavn == navn)



               return sublistNavne.ToArray();

Reply With Quote
  #2 (permalink)  
Old April 25th, 2008, 04:42 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts

I'm not 100% but can you try changing it to this and see if that works:


/- Sam Judson : Wrox Technical Editor -/
Reply With Quote
  #3 (permalink)  
Old April 26th, 2008, 04:28 AM
Authorized User
Join Date: Apr 2008
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts

Thanks for your replay.. but it did not work.. But I found this solution, by using the LINQ listBox2.Items.AddRange(f1.datoer_GetAllDatoSublis t().Cast<object>().ToArray());

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ArrayList Mogg-Way C# 2005 5 February 12th, 2008 04:05 PM
Return an arraylist Morrislgn VB.NET 2002/2003 Basics 1 March 24th, 2006 04:42 AM
Help with an arraylist crazy-nun General .NET 4 July 14th, 2005 03:32 AM
UTC DateTime to Local DateTime r_ganesh76 SQL Server 2000 1 April 4th, 2005 08:21 AM
ArrayList kobystud C# 4 May 25th, 2004 02:05 PM

All times are GMT -4. The time now is 01:22 AM.

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