[Gtk-sharp-list] Query all values from TreeView
David S
buttink at gmail.com
Thu Jul 8 04:08:27 EDT 2010
Ok sorry jumped the gun on the reply lol here is what you would want
List<string> rowData = new List<string>();
mymodel.Foreach( (model, path, iter) => {
string data = model.GetValue( iter, 0 ) as string; // could cut this out
... but whatever
// manipulate data
rowData.Add( data );
return false; // a return value of true stops the foreach
} );
string allRows = rowData.Aggregate( (current,next) => current + next );
On Thu, Jul 8, 2010 at 4:00 AM, David S <buttink at gmail.com> wrote:
> There is an actual "Foreach" method that you give a TreeModelForeachFunc(
> TreeModel, TreePath, TreeIter ) for the TreeModels.
>
> so you could do something like this
>
> mymodel.Foreach( (model, path, iter) => {
> string data = model.GetValue( iter, 0 );
> // manipulate data
> return false; // a return value of true stops the foreach
> } );
>
> On Thu, Jul 8, 2010 at 3:09 AM, LordPhoenix <lordphoenix at free.fr> wrote:
>
>> Le Wed, 7 Jul 2010 08:12:31 -0700 (PDT),
>> MethodCZ <methodcz at gmail.com> a écrit :
>>
>> >
>> > Hi,
>> >
>> > In the morning i didn't think it will be necessary to ask here,
>> > however after all day which i spent trying to figure how to get
>> > values from my TreeView, i'm kinda hopeless.
>> >
>> > My problem is that i have have a TreeView with Model and everything
>> > required where user can add/remove nodes. (it's actually only one
>> > level of nodes so it's not really tree). User can add multiple nodes.
>> > This is ok and i had no problem to wrote that. Problem is that i need
>> > to join all the values of all the nodes into one single string
>> > variable. (My treeview has only 1 column)
>> >
>> > So for example user adds values "a", "b", "c" and i want to join it
>> > into string val = "abc".
>> >
>> > I did some research on this and found few ideas how to do this from
>> > using TreeModel.Foreach function to some suggestions to use Do cycle
>> > etc. but none of them worked :{
>> >
>> > Thanks for any ideas :]
>>
>> Here is my way to browse ListStore:
>>
>> TreeIter iter;
>> if(ListStore.GetIterFirst(out iter)){
>> do{
>> myvalue = ListStore.GetValue(iter,column);
>> //make treatment on myvalue.
>> while(ListStore.NextIter(ref iter));
>> }
>> }
>>
>> Can do same way with TreeStore I think.
>>
>> PS: Sorry for my bad English I don't speak it very often.
>>
>> _______________________________________________
>> Gtk-sharp-list maillist - Gtk-sharp-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20100708/f79fe0b6/attachment-0001.html
More information about the Gtk-sharp-list
mailing list