Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gtk# and treeview: how to get "selected" item?

Tags:

gtk

gtk#

i can't understand in GTK# how to get the selected item of a treeview. My code example: Here, i load data in tvStock

        Gtk.TreeViewColumn marketCol = new Gtk.TreeViewColumn ();
            marketCol.Title = "Market";

            tvstock.AppendColumn(marketCol);

            Gtk.TreeIter iter = stockListStore.AppendValues ("Dax30");      

            stockListStore.AppendValues(iter, "Adidas");
            stockListStore.AppendValues(iter, "Commerzbank");

            iter = stockListStore.AppendValues ("Cac40");       
            stockListStore.AppendValues(iter, "Bnp Paribas");
            stockListStore.AppendValues(iter, "Veolia");

            iter = stockListStore.AppendValues ("FtseMib");     
            stockListStore.AppendValues(iter, "Fiat");
            stockListStore.AppendValues(iter, "Unicredit");

            tvstock.Model = stockListStore;

            // Create the text cell that will display the artist name
            Gtk.CellRendererText marketNameCell = new Gtk.CellRendererText ();
            // Add the cell to the column
            marketCol.PackStart (marketNameCell, true);     

            // Tell the Cell Renderers which items in the model to display
            marketCol.AddAttribute (marketNameCell, "text", 0);         

On my OnTvstockRowActivated , how can i get the selected row ? Thanks

like image 456
stighy Avatar asked Nov 18 '10 17:11

stighy


People also ask

What is GTK full form?

The Full form of GTK is good to know, or GTK stands for good to know, or the full name of given abbreviation is good to know.

Is GTK a programming language?

GTK is written using the C programming language, but its also available to various programming languages through language bindings, which allow writing GTK applications in the style of those languages. Language bindings are relatively easy to create because GTK is designed with them in mind.

What does GTK stand for Linux?

GTK is commonly and incorrectly thought to stand for "GNOME ToolKit", but is actually stands for "GIMP ToolKit" because it was first created to design an user interface for GIMP. GTK is an object-oriented toolkit written in C (GTK itself is not a language). GTK is entirely open-source under the LGPL license.

What is GTK in Java?

It is part of the official GNOME language bindings suite and provides a set of libraries allowing developers to write computer programs for GNOME using the Java programming language and the GTK cross-platform widget toolkit. Java-gnome. Initial release. 0.99 / January 20, 1999.


1 Answers

You have the path to the row in args, you can gen an iter from it.

protected virtual void OnTvstockRowActivated (object o, Gtk.RowActivatedArgs args)
{
    var model = tvstock.Model;
    TreeIter iter;
    model.GetIter (out iter, args.Path);
    var value = model.GetValue (iter, 0);
    Console.WriteLine (value);
}
like image 133
silk Avatar answered Oct 23 '22 04:10

silk