[Mono-list] Append and retrieve a row from a Gtk.TreeView

Vincent Arnoux vincent.arnoux@rfo.atmel.com
Tue, 22 Feb 2005 17:43:29 +0100


Hello,
I am coding and application in which I need to have a 2 columns list 
displaying text.
 From the fnuction below "makeList", I can populate my list, but there 
is no way to add another row from another function (after the button is 
clicked).
I don't understand why:
- jobsStore.Data.Count is 0
- Appending the value outof the initial function looks to be not working
Could please somebody have a look at it and tell me what's wrong ? I 
don't know neither how to retrieve or remove a row.
Does someone have a simple application using these functions ?

    public void makeList()
    {
        jobsStore = new ListStore (typeof (string), typeof (string));

        for (int i=0; i < 10; i++)
        {
            TreeIter iter = jobsStore.AppendValues ("Demo " + i, "Data " 
+ i);
        }

        tv = new TreeView ();
        tv.Model = jobsStore;
        tv.HeadersVisible = true;
        tv.RulesHint = true;
        tv.Reorderable = true;
        Console.WriteLine(jobsStore.Data.Count);

        tv.AppendColumn ("Demo", new CellRendererText (), "text", 0);
        tv.AppendColumn ("Data", new CellRendererText (), "text", 1);
        sw.Add(tv);
        tv.Show();
    }

    public void on_addJobButton_clicked(object o, EventArgs args)
    {
        makeList();
        FileSelection fs = new FileSelection("Choose a file:");
        int fsAns = fs.Run();
        fs.Hide();
        if(fsAns != (int) ResponseType.Ok)
            return;
        string destination = fs.Filename;
        jobsStore.AppendValues ("Demo ", fs.Filename);
        tv.Show();
    }



Thank you very much,
Vincent