add small example for selection

svn path=/trunk/gtk-sharp/; revision=22041
This commit is contained in:
John Luke 2004-01-13 22:04:34 +00:00
parent 6507489ef9
commit cc654d5a06
2 changed files with 69 additions and 2 deletions

View File

@ -1,3 +1,7 @@
2004-01-13 John Luke <jluke@cfl.rr.com>
* en/Gtk/TreeSelection.xml: add example
2004-01-12 Hector E. Gomez Morales <hgomez_36@flashmail.com>
* en/Gtk/Ctree.xml
@ -7,7 +11,7 @@
* en/Gtk/Widget.xml: Documented the remaining methods and properties.
* en/Gtk/Window.xml: Documented all methods excepts the overloads and all the properties.
2004-01-08 John Luke <jluke@cfl.rr.com>
2004-01-11 John Luke <jluke@cfl.rr.com>
* en/Gtk/RadioButton.xml:
* en/Gtk/Notebook.xml:

View File

@ -78,6 +78,69 @@
<remarks>
<para>See also, <see cref="M:Gtk.TreeSelection.UnselectPath(Gtk.TreePath)" /> and <see cref="M:Gtk.TreeSelection.UnselectAll()" />.</para>
</remarks>
<example>
<code language="C#">
using System;
using Gtk;
using GtkSharp;
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 &lt; 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 ();
}
}
</code>
</example>
</Docs>
</Member>
<Member MemberName="IterIsSelected">
@ -432,4 +495,4 @@
</Docs>
</Member>
</Members>
</Type>
</Type>