[Mono-list] TreeView, TreeStore and TreeColumn (Newbie)

RibeiroGustavoTI ribeirogustavoti at gmail.com
Wed Jul 30 08:46:48 EDT 2008


Hi,

Im trying to create a Gtk.TreeView that suport a ToggleButton.

I create it normally but i dont know how to create the 
Gtk.TreeViewColumn and Gtk.TreeStore.

Please, can somebody see my code and tell where did i wrong.

In the example below, i create a treeview for songs, that has two columns:
    1: Song;
    2: Delete (whether the song must be deleted or not);

Song is a normal text, but Delete is a ToggleButton.

Here's the code:

public class TreeViewExample
{
	public static void Main ()
	{
		Gtk.Application.Init ();
		new <http://www.google.com/search?q=new+msdn.microsoft.com> TreeViewExample ();
		Gtk.Application.Run ();
	}
	
	public TreeViewExample ()
	{
		Gtk.Window window = new <http://www.google.com/search?q=new+msdn.microsoft.com> Gtk.Window ("TreeView Example");
		window.SetSizeRequest (500,200);
 
		Gtk.TreeView tree = new <http://www.google.com/search?q=new+msdn.microsoft.com> Gtk.TreeView ();
 
		window.Add (tree);
 
		Gtk.TreeViewColumn Song = new <http://www.google.com/search?q=new+msdn.microsoft.com> Gtk.TreeViewColumn ("Song",new Gtk.CellRendererText(),"text",0);

		Gtk.TreeViewColumn Delete = new <http://www.google.com/search?q=new+msdn.microsoft.com> Gtk.TreeViewColumn ("Delete?",new Gtk.CellRendererToggle(),"toggle",1);
 
		tree.AppendColumn (Song);
		tree.AppendColumn (Delete);
 
		Gtk.ListStore musicListStore = new <http://www.google.com/search?q=new+msdn.microsoft.com> Gtk.ListStore (typeof <http://www.google.com/search?q=typeof+msdn.microsoft.com> (string), typeof <http://www.google.com/search?q=typeof+msdn.microsoft.com> (bool));
 
		tree.Model = musicListStore;
 
		window.ShowAll ();
	}
}


Thanks for any help, and sorry for any mistake, my english is not very good.

Gustavo.


More information about the Mono-list mailing list