[Gtk-sharp-list] Query getting values from treeview

Andy York andy at brdstudio.net
Wed Jan 7 19:11:55 EST 2009


It is the foreach function you are looking for here is an example of usage

    // to call the function
    MyTreeStore.Foreach(new TreeModelForeachFunc(ForeachTask));

        private bool ForeachTask(Gtk.TreeModel model, Gtk.TreePath path, 
Gtk.TreeIter iter)
        {
            if(model.GetValue(iter, 0).ToString() = = strSearchVal) // 
access the column via its column index
                return true; // returning true exits the loop
               
            return false; // returning false continues the loop
        }

Gtk# keeps track of the rows (or nodes if you want) using an internal 
value Gtk.TreeIter or by the Gtk.TreePath
It takes some time to get used to but once you do it will be come as 
easy as the MS methods. The Mono documentation is very helpful as is 
krugal.org

I hope this helps
SpoodyGoon

libin wrote:
>  
> Hi All,
>  
> i have a GTK#  treeview which have two columns Name and value.
> I am populating the values of this in a liststore and i am adding this 
> to the treeview.
> Now for testing purpose i want to itetrate through all the values 
> inside this two columns.
>  
>  
> This is how the code look like,
> ------------------------------------------------------------------------------------------------------------------------------------
> inside a foreach loop
>  
>
> {
>
> strName = childNode.Attributes.GetNamedItem("name").Value;
>
> strValue = childNode.Attributes.GetNamedItem("value").Value;
>
> listStore.AppendValues(strValue,strName);
>
> }
>
>  
>
> then adding this liststore to treeview
>
>  
>
> ListView= new TreeView(listStore);
>
> ListView.AppendColumn("Name", new CellRendererText(), "text", 0);
>
> ListView.AppendColumn("Value", new CellRendererText(), "text", 1);
>
>  
>
> ListWindow.Add(ListView);
>
> --------------------------------------------------------------------------------------------------------------------------------------
>  
> Anyboby pls provide me the syntax for iterating through each values in 
> each columns.
>  
> Thanks a lot!!!
>  
> Libin
>  
>
> * Please do not print this email unless it is absolutely necessary. *
>
> The information contained in this electronic message and any 
> attachments to this message are intended for the exclusive use of the 
> addressee(s) and may contain proprietary, confidential or privileged 
> information. If you are not the intended recipient, you should not 
> disseminate, distribute or copy this e-mail. Please notify the sender 
> immediately and destroy all copies of this message and any attachments.
>
> WARNING: Computer viruses can be transmitted via email. The recipient 
> should check this email and any attachments for the presence of 
> viruses. The company accepts no liability for any damage caused by any 
> virus transmitted by this email.
>
> www.wipro.com
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
>   
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - http://www.avg.com 
> Version: 8.0.176 / Virus Database: 270.10.5/1881 - Release Date: 1/7/2009 5:59 PM
>
>   





More information about the Gtk-sharp-list mailing list