gtk-sharp 2.12.0.0 Gtk# is thread aware, but not thread safe; See the Gtk# Thread Programming for details. GLib.Object The selection object for .

TreeSelection provides a single class for managing selection information on the List/Tree widget.

A TreeSelection object is automatically created when a new widget is created and is inherently tied to it. A TreeSelection cannot exist independently of a . Selection information is retrieved from the with the property.

TreeSelection can check the selection status of the tree, as well as select and deselect individual rows. Selection is done completely on the view. As a result, multiple views of the same model can have completely different selections. Additionally, you cannot change the selection of a row that is not currently displayed by the view without expanding its parents first.

One of the important things to remember when monitoring the selection of a view is that the event is mostly a hint. For example, it may only fire once when a range of rows is selected. It may also fire when nothing has happened, such as when is called on a row that is already selected.

`using System; using Gtk; class Selection { static void Main () { Application.Init (); Window win = new Window ("TreeSelection sample"); win.DeleteEvent += OnWinDelete; TreeView tv = new TreeView (); tv.AppendColumn ("Items", new CellRendererText (), "text", 0); ListStore store = new ListStore (typeof (string)); store.AppendValues ("item 1"); store.AppendValues ("item 2"); tv.Model = store; tv.Selection.Changed += OnSelectionChanged; win.Add (tv); win.ShowAll (); Application.Run (); } static void OnSelectionChanged (object o, EventArgs args) { TreeIter iter; TreeModel model; if (((TreeSelection)o).GetSelected (out model, out iter)) { string val = (string) model.GetValue (iter, 0); Console.WriteLine ("{0} was selected", val); } } static void OnWinDelete (object o, DeleteEventArgs args) { Application.Quit (); } }`
- Constructor
  2.12.0.0
  Protected constructor.
- Constructor
  2.12.0.0
  System.Obsolete
  a
  Protected Constructor.
  Chain to this constructor if you have manually registered a native value for your subclass.
- Constructor
  2.12.0.0
  Pointer to the C object.
  Internal constructor

  This is an internal constructor, and should not be used by user code.

- Event
  2.12.0.0
  GLib.Signal("changed")
  System.EventHandler Raised when the selection (may have) changed.

  This event is mostly a hint. It may only be raised once when a range of rows are selected, and it may occasionally be raised when nothing has happened.

- Method
  2.12.0.0
  System.Int32 Get the number of selected rows. The number of selected rows
- Method
  2.12.0.0
  System.Boolean `` The position that was selected. Gets information about the currently selected node. if a row is selected. This convenience method doesnt require an out . It is useful in the case that you already have a copy of the TreeModel.
- Method
  2.12.0.0
  System.Boolean `` `` A convenient accessor to the that this TreeSelection's is associated with. The position that was selected. Get information about the currently selected node. if a row was selected.

  This method will not work if the TreeSelection has been set to . In that case you should use .

- Method
  2.12.0.0
  Gtk.TreePath[] Returns an array of s representing the selected rows. Selected rows in an array of s
- Method
  2.12.0.0
  Gtk.TreePath[] `` The model the is bound to. Returns an array of s representing the selected rows. Selected rows in an array of s
- Property
  2.12.0.0
  GLib.GType GType Property. a Returns the native value for .
- Method
  2.12.0.0
  System.Boolean `` The tree location to check Determine if the iter is selected. if the tree node specified by is selected, otherwise.

  See also .

- Property
  2.12.0.0
  Gtk.SelectionMode Manages the way rows can be selected. The current mode dictating selection behaviour.

  Rows may be deselected by changing this property. For example, if rows are selected and the mode is changed to or .

- Method
  2.12.0.0
  GLib.DefaultSignalHandler(ConnectionMethod="OverrideChanged", Type=typeof(Gtk.TreeSelection))
  System.Void Default handler for the event. Override this method in a subclass to provide a default handler for the event.
- Method
  2.12.0.0
  System.Boolean `` The path to a node whose selected status should be checked. Determines whether a has been selected in this . if is selected, otherwise.
- Method
  2.12.0.0
  System.Void Selects every node in this .

  The must be set to for this method to work.

- Method
  2.12.0.0
  System.Void `` The delegate that should be called for each selected row. Invokes the delegate passed in by for each selected row in the .

  This method is useful when the of this TreeSelection is set to . It is currently the only way to access selection information for multiple rows. See the class overview for an example on how to effectively use this method for selection tracking.

- Property
  2.12.0.0
  Gtk.TreeSelectionFunc A hook into selection and unselection a

  If set, is called before any node is selected or unselected, giving some control over which nodes are selected. The select function should return if the state of the node may be toggled, and if the state of the node should be left unchanged.

- Method
  2.12.0.0
  System.Void `` Indicates which row to select. Selects the specified .

  See also and .

- Method
  2.12.0.0
  System.Void `` A row to be selected. Selects the specified row that represents.
- Method
  2.12.0.0
  System.Void `` `` The first node to select on the tree. The last node to select on the tree. Selects all the nodes that appear between and .
- Method
  2.12.0.0
  System.Obsolete("Replaced by SelectFunction property.")
  System.Void `` `` `` A delegate to invoke before a node is (un)selected. ignored ignored Add a hook into selection and unselection. This method is obsolete. New code should use the property.
- Property
  2.12.0.0
  Gtk.TreeView Get the that this is associated with. The that this is tied to.

  A object can only be retrieved from a . That is done with its property.

- Method
  2.12.0.0
  System.Void Sets all nodes in the as unselected.
- Method
  2.12.0.0
  System.Void `` The tree position that should be deselected. Deselects the specified position in the tree.

  See also, and .

  `using System; using Gtk; class TreeSelectionSample { Label selected; static void Main () { Application.Init (); new TreeSelectionSample (); Application.Run (); } TreeSelectionSample () { Window win = new Window ("TreeView selection sample"); win.SetDefaultSize (400, 300); win.DeleteEvent += new DeleteEventHandler (OnWinDelete); HBox hbox = new HBox (false, 0); TreeView tv = new TreeView (); tv.Selection.Changed += new EventHandler (OnSelectionChanged); tv.AppendColumn ("items", new CellRendererText (), "text", 0); TreeStore store = new TreeStore (typeof (string)); for (int i = 0; i < 10; i++) { store.AppendValues ("item " + i.ToString ()); } tv.Model = store; hbox.PackStart (tv); selected = new Label (); hbox.PackStart (selected); win.Add (hbox); win.ShowAll (); } void OnSelectionChanged (object o, EventArgs args) { TreeSelection ts = (TreeSelection) o; TreeIter iter; TreeModel model; ts.GetSelected (out model, out iter); selected.Text = (string) model.GetValue (iter, 0); } void OnWinDelete (object o, DeleteEventArgs args) { Application.Quit (); } }`
- Method
  2.12.0.0
  System.Void `` A node in the tree. Deselects the tree node that refers to.

  See also .

- Method
  2.12.0.0
  System.Void `` `` to begin range. to end range. Unselects everything between one path and another.
- Property
  2.12.0.0
  System.IntPtr Get the data associated with the that has been setup for this . The raw data that was set when was called.