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

Jacob Ilsø Christensen jacobilsoe at gmail.com
Wed Mar 7 11:00:32 EST 2007


Hi.

On 3/7/07, Daniel Dieterle <daniel at dieterle.ws> wrote:
> Hi,
>
> 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:

I think you need to do this:

gui.Autoconnect(this);

before using any widgets. If not your treeview1 variable wont be initialized.

/Jacob

> ___
> 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?
>
> Thanks,
> Daniel.
>
>
>
>
> 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
> Tricks");
>                 treeview1.Model = musicListStore;
>
>                 gui.Autoconnect(this);
>         }
>
>         // boutton lire
>         void on_button1_clicked (object o, EventArgs e)
>         {
>         }
> }
>
> class MainClass {
>
>         static void Main () {
>
>                 Gtk.Application.Init();
>                 BrowserWindow bw = new BrowserWindow();
>                 Gtk.Application.Run();
>         }
> }
> ________________________________________________________
>
> >
> > 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:
> >
> >
> >
>
> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
>


More information about the Gtk-sharp-list mailing list