V
V
Vetal Matitskiy2015-06-03 21:16:10
Mono
Vetal Matitskiy, 2015-06-03 21:16:10

How to work with radio buttons for TreeView widget in MonoDevelop?

Good afternoon, dear development gurus
I am writing a small task manager and trying to use MonoDevelop for this.
Tell me, please, how can I implement the work with switches (check box) in Mono? According to the documentation on the site, I found how you can create collapsible lists for TreeView. The documentation states that a TreeView cell can be rendered as a CellRendererToggle (Used to display a check box), but I can't find any more descriptions on working with this type. I want to implement the ability to set and reset the switch status and then change the data in the model. Now it turned out to only display a column of switches, but I don’t know how to change their status, how the
full project code lies on https://github.com/veitsi/todonet
Now I form the list of tasks like this:

private void TreeInit ()
  {
    Gtk.TreeViewColumn taskColumn = new Gtk.TreeViewColumn ();
    taskColumn.Title = "Task description";
    Gtk.CellRendererText taskTextCell = new Gtk.CellRendererText ();
    taskColumn.PackStart (taskTextCell, true);

    Gtk.TreeViewColumn statusColumn = new Gtk.TreeViewColumn ();
    statusColumn.Title = "status";
    Gtk.CellRendererToggle statusCell = new Gtk.CellRendererToggle ();
    statusColumn.PackStart (statusCell, true);

    tree.AppendColumn (taskColumn);
    tree.AppendColumn (statusColumn);
    taskColumn.AddAttribute (taskTextCell, "text", 0);
    statusColumn.AddAttribute (statusCell, "text", 1);
  }

  public void TreeBuild (ToDoList todo)
  {
    //textview.Buffer.Text = "Загрузили список задач\n";
    this.TreeInit ();

    Gtk.TreeStore todoListStore = new Gtk.TreeStore (typeof(string), typeof(string));
    Gtk.TreeIter iter;
    foreach (Task t in todo.tasks) {
      iter=todoListStore.AppendValues (t.text);
      if (t.subs.Count > 0) {
        foreach (SubTask s in t.subs)
          todoListStore.AppendValues (iter, s.text, "");
      }
    }

    tree.Model = todoListStore;
  }

the program window looks like this
e8ea01823e3b4f85b192370fee753c87.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question