[Gtk-sharp-list] gtk newbie

Antonio Martínez Alvarez amartinez@atc.ugr.es
Tue, 13 Apr 2004 18:49:39 +0200


Marco Rego wrote:

>Please pardon my high ignorance in gtk ...
>
>Could someone tell me why the the example below doesn't work ? I mean,
>it builds but when I try to execute it ends with a
>nullreferenceexception.
>
>using Gtk;
>using System;
>
>public class MyWindow : Window {
>
>  public MyWindow() {
>    this.Show();
>  }
>
>}
>
>public class TestMyWindow {
>
>  public static void Main(string[] args) {
>    Application.Init ();
>    new MyWindow();
>    Application.Run();
>  }
>
>}
>
>
>I know if don't inherit MyWindow from Window and in instead put a Window
>object as a member of MyWindow it works.
>TIA.
>
>Marco.
>  
>
Hello Marco. Take a look on the constructor.
Your code works with a little change :)

using Gtk;
using System;

public class MyWindow : Window {
  public MyWindow(string cad):base(cad) {
    this.Show();
  }
}

public class TestMyWindow {
  public static void Main(string[] args) {
    Application.Init ();
    new MyWindow("My app");
    Application.Run();
  }
}

--
Antonio Martínez