Adding the contents of a list to a MTD

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Adding the contents of a list to a MTD

Paul Johnson
Hi,

Got an interesting one here.

I have a list of strings that I want to put into a RadioGroups set of
RadioElements.

I thought that I could do something like

var section = new Section()
{
   foreach(string s in myList)
     new RadioElement(s, "mygroup"),
}

but that's no good (you can't use a foreach inside of the section).

Next idea was to create a List<RadioElements) and create things that
way. Only problem there is that you still can't add the list contents to
the section.

Is there a way to do this?

Paul
--
"Space," it says, "is big. Really big. You just won't believe how
vastly, hugely, mindbogglingly big it is. I mean, you may think it's a
long way down the road to the chemist's, but that's just peanuts to
space, listen..."
Hitch Hikers Guide to the Galaxy, a truly remarkable book!

_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Adding the contents of a list to a MTD

jawbrey
you should be able to do something like this

                    new Section (){
                        from name in myList
                            select (Element) new RadioElement (name, "mygroup")
                    }


On Tue, Jun 4, 2013 at 8:33 PM, Paul Johnson <[hidden email]> wrote:
Hi,

Got an interesting one here.

I have a list of strings that I want to put into a RadioGroups set of RadioElements.

I thought that I could do something like

var section = new Section()
{
  foreach(string s in myList)
    new RadioElement(s, "mygroup"),
}

but that's no good (you can't use a foreach inside of the section).

Next idea was to create a List<RadioElements) and create things that way. Only problem there is that you still can't add the list contents to the section.

Is there a way to do this?

Paul
--
"Space," it says, "is big. Really big. You just won't believe how vastly, hugely, mindbogglingly big it is. I mean, you may think it's a long way down the road to the chemist's, but that's just peanuts to space, listen..."
Hitch Hikers Guide to the Galaxy, a truly remarkable book!

_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch


_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Adding the contents of a list to a MTD

Nic Wise
Jason is right - use linq or a function which returns an
IEnumerable<RadioElement> and takes in your list :)

On 5 June 2013 02:46, Jason Awbrey <[hidden email]> wrote:

> you should be able to do something like this
>
>                     new Section (){
>                         from name in myList
>                             select (Element) new RadioElement (name,
> "mygroup")
>                     }
>
>
>
> On Tue, Jun 4, 2013 at 8:33 PM, Paul Johnson <[hidden email]>
> wrote:
>>
>> Hi,
>>
>> Got an interesting one here.
>>
>> I have a list of strings that I want to put into a RadioGroups set of
>> RadioElements.
>>
>> I thought that I could do something like
>>
>> var section = new Section()
>> {
>>   foreach(string s in myList)
>>     new RadioElement(s, "mygroup"),
>> }
>>
>> but that's no good (you can't use a foreach inside of the section).
>>
>> Next idea was to create a List<RadioElements) and create things that way.
>> Only problem there is that you still can't add the list contents to the
>> section.
>>
>> Is there a way to do this?
>>
>> Paul
>> --
>> "Space," it says, "is big. Really big. You just won't believe how vastly,
>> hugely, mindbogglingly big it is. I mean, you may think it's a long way down
>> the road to the chemist's, but that's just peanuts to space, listen..."
>> Hitch Hikers Guide to the Galaxy, a truly remarkable book!
>>
>> _______________________________________________
>> MonoTouch mailing list
>> [hidden email]
>> http://lists.ximian.com/mailman/listinfo/monotouch
>
>
>
> _______________________________________________
> MonoTouch mailing list
> [hidden email]
> http://lists.ximian.com/mailman/listinfo/monotouch
>



--
Nic Wise
t.  +44 7788 592 806 | @fastchicken
b. http://www.fastchicken.co.nz/
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Loading...