Table des matières

GTK#

GTK# est la librarie pour produire l'interface avec Mono.

TreeView

TreeView avec ListStore

tree.AppendColumn ("Filename", new Gtk.CellRendererText (), "text", 0);
tree.AppendColumn ("Title", new Gtk.CellRendererText (), "text", 1);
tree.AppendColumn ("ISBN", new Gtk.CellRendererText (), "text", 2);
 
Gtk.ListStore bookListStore = new Gtk.ListStore (typeof (string), typeof (string), typeof (string));
bookListStore.AppendValues ("Title", "ISBN", "Publisher");
 
tree.Model = bookListStore;

Obtenir l'item sélectionné

public static void TreeSetup(Gtk.TreeView tree, ListStore bookListStore)
{
    // Tout le setup du TreeView, création de colonnes, ajout de colonnes, ajout du modèle, etc. 
    tree.CursorChanged += new EventHandler(OnTreeCursorChanged);
}
 
private static void OnTreeCursorChanged(object sender, EventArgs e)
{
    TreeSelection selection = (sender as TreeView).Selection;
    TreeModel model;
    TreeIter iter;
 
    if(selection.GetSelected(out model, out iter))
    {
        Book book = (Book) model.GetValue (iter, 0);
	Console.WriteLine(book.Filename);
    }
}

TreeViewColumn

Gtk.TreeViewColumn titleColumn = new Gtk.TreeViewColumn ();
titleColumn.Title = "Title";
Gtk.CellRendererText titleCell = new Gtk.CellRendererText ();
titleColumn.PackStart (titleCell, true);

Propriétés

Nom Type Accès
Alignment float Read / Write
Clickable boolean Read / Write
Expand boolean Read / Write
FixedWidth int Read / Write
MaxWidth int Read / Write
MinWidth int Read / Write
Reorderable boolean Read / Write
Resizable boolean Read / Write
Sizing GtkTreeViewColumnSizing Read / Write
SortColumnId int Read / Write
SortIndicator boolean Read / Write
SortOrder GtkSortType Read / Write
Spacing int Read / Write
Title char* Read / Write
Visible boolean Read / Write
Widget GtkWidget* Read / Write
Width int Read

Source

Entry

Propriétés

Nom Type Accès
Editable bool Read / Write
MaxLength int Read / Write
Text string Read / Write
TruncateMultiline bool Read / Write
Visibility bool Read / Write
WidthChars int Read / Write

Contient que quelques propriétés.

Source