Je me fais une exception quand je veux ajouter des éléments dans mon NodeView:Exception dans Gtk.NodeView.AddNode
Exception dans Gtk # délégué de rappel Remarque: Les applications peuvent utiliser pour GLib.ExceptionManager.UnhandledException gérer l'exception. System.IndexOutOfRangeException: l'index du tableau est hors limites. à Gtk.NodeStore.get_value_cb (Int32 node_idx, Int32 col, GLib.Value & val) [0x00000] à GLib.ExceptionManager.RaiseUnhandledException (System.Exception e, is_terminal Boolean) à Gtk.NodeStore.get_value_cb (Int32 node_idx, Colonne Int32, Valeur ByRef val) à Gtk.Application.gtk_main() à Gtk.Application.Run() à IcePipe.Program.Main (Arguments System.String []) dans/home/tomcatfort/Projects/IcePipe/GUI/Program.cs: ligne 18
Je crée ce code en mono 2.4.2.3. Et j'utilise Gtk #. Vous pouvez télécharger mon code à partir de ce lien: http://tomcatfort.net/priv/IcePipe.tar.gz
Je ne sais pas ce qui cause le problème, je ne trouve rien qui pourrait être le problème.
Voici le code qui lève l'exception:
public MainWindow() : base(Gtk.WindowType.Toplevel)
{
this.Build();
mContactsNodeStore.AddNode(new Contact("Kutya", new Gdk.Pixbuf("Img/Refresh24x24.png"))); //AddNode(...) throws it.
}
Création d'une instance de contact ne provoque pas exception, je l'ai essayé.
Voici comment je l'ai fait l'NodeView:
mContactsNodeStore = new NodeStore(typeof(Contact));
mContactsNodeView = new NodeView(mContactsNodeStore);
mContVBox2.PackStart(mContactsNodeView, true, true, 0);
mContactsNodeView.AppendColumn("Icon", new CellRendererPixbuf(), "pixbuf", 0);
mContactsNodeView.AppendColumn("Name", new CellRendererText(), "text", 1);
Et voici Contact:
[Gtk.TreeNode (ListOnly = true)] //What is this for?
public class Contact : Gtk.TreeNode, IDisposable
{
#region Fields and properties
[Gtk.TreeNodeValue (Column = 1)]
private string pName;
/// <summary>
/// Gets or sets the name of the contact.
/// </summary>
public string Name {
get {return pName;}
protected set {pName = value;}
}
[Gtk.TreeNodeValue (Column = 0)]
private Gdk.Pixbuf pIcon;
/// <summary>
/// Gets or sets the icon of the contact.
/// </summary>
public Gdk.Pixbuf Icon {
get {return pIcon;}
protected set {pIcon = value;}
}
#endregion
#region Constructor adn disposer
/// <summary>
/// Initialize the contact.
/// </summary>
public Contact(string aName, Gdk.Pixbuf aIcon) : base()
{
pName = aName;
pIcon = aIcon;
}
/// <summary>
/// Release allocated resources.
/// </summary>
public void Dispose()
{
Disposing(this, null);
}
#endregion
#region Events
/// <summary>
/// Fired when the contact is being disposed.
/// </summary>
public event EventHandler Disposing;
#endregion
}
Veuillez ajouter la partie du code où l'exception est renvoyée à votre question. Merci. – Bobby
Le commentaire de Second Bobby. On dirait que vous essayez d'obtenir une ligne qui n'existe pas, mais sans regarder le code, il est difficile de dire ce qui se passe. – seanhodges