2010-11-18 25 views
3

GTK # içinde ağaç görünümünde seçilen öğeyi nasıl anlayamıyorum. Benim kod örneği: Burada, i seçili satır almak nasıl, OnTvstockRowActivated benim Açık Gtk # ve treeview: "seçili" öğe nasıl alınır?

 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);   

tvStock

veri yüklemek? Teşekkürler

cevap

5

Satırlarda satır yolunuz var, bundan bir iter yapabilirsiniz.

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); 
} 
İlgili konular