[Gtk-sharp-list] R: GTK# with a treeview: simple example

Daniel Dieterle daniel at dieterle.ws
Wed Mar 7 07:42:11 EST 2007


On Tue, 2007-03-06 at 17:00 +0100, Salvatore Scarciglia wrote:
> http://laas.altervista.org/tutorials/tview_1.php
your site is intersting and motivating.

My mistake is easy. How can i write such a code.
The lines where the collumns are added to the treeview are never
executed because they are just after the attributes.

If i move the certain lines in a method like on_button1_clicked
everything goes well. :-)

BUT if i write them in the constructor it won't work. Error:
System.NullReferenceException: Object reference not set to an  
instance of an object
in <0x00116> BrowserWindow:.ctor ()

I can't see where i should have an object which is NULL?!
Who can help me?


My code:
class BrowserWindow
         [Widget] Gtk.TreeView treeview1;

         public BrowserWindow ()
                 Glade.XML gui = new Glade.XML ("./browser.glade",  
"window1", "Hallo");

                 Gtk.ListStore musicListStore = new Gtk.ListStore  
(typeof (string), typeof (string));
                 treeview1.AppendColumn ("Nom", new  
Gtk.CellRendererText (), "text", 0);
                 treeview1.AppendColumn ("URL", new  
Gtk.CellRendererText (), "text", 1);

                 musicListStore.AppendValues ("Garbage", "Dog New
                 treeview1.Model = musicListStore;


         // boutton lire
         void on_button1_clicked (object o, EventArgs e)

class MainClass {

         static void Main () {

                 BrowserWindow bw = new BrowserWindow();

> Regards,
> Salvatore [aka LAAS]
> > -----Messaggio originale-----
> > 
> > Hi everybody, 
> > 
> > i wrote a simple program in C#. I'm a beginner with C# and GTK#. 
> > The graphics i layouted with Glade. When i want to add a 
> > column, the compiler complains always with a error. 
> > I found no information, how to add a column while the windows 
> > is with Glade formatted and in C# written. 
> > 
> > My code is the following: 

More information about the Gtk-sharp-list mailing list