AddRange problem

I’m having trouble with this in a ListBox control:

self.listBox1.Items.AddRange([‘a’, ‘b’, ‘c’])

I get the error

:0:in InitializeComponent': wrong number or type of arguments forAddRange’ (ArgumentError)

What’s the correct syntax here?

(I think this used to work)

Dermot

For some reason it seems to be passing it in as

self.listBox1.Items.AddRange(‘a’, ‘b’, ‘c’)

Odd…

Regardless though, as a work around for now you can do this:

[‘a’,‘b’,‘c’].each {|item| self.listBox1.Items.Add item}

On Feb 8, 2008 5:14 AM, Dermot H. [email protected] wrote:

(I think this used to work)

Dermot

Posted via http://www.ruby-forum.com/.


Ironruby-core mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core


Michael L.
[Polymath Programmer]
http://michaeldotnet.blogspot.com

Michael L. wrote:

For some reason it seems to be passing it in as

self.listBox1.Items.AddRange(‘a’, ‘b’, ‘c’)

Odd…

Regardless though, as a work around for now you can do this:

[‘a’,‘b’,‘c’].each {|item| self.listBox1.Items.Add item}

Unfortunately I can’t do that … I have to use AddRange because that’s
what the ListBox control + Form Designer generates. So I think I’m stuck
:frowning:

Dermot

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs