0

我想要一个Gtk.TreeView具有第一列的组合框,我将能够在其中选择我希望第一列成为的值。下面是我的代码。

        Gtk.TreeViewColumn compteColumn = new TreeViewColumn();
        Gtk.CellRendererCombo compteCellCombo = new CellRendererCombo();
        compteColumn.PackStart(compteCellCombo, true);
        compteColumn.AddAttribute(compteCellCombo, "text", 0);
        compteColumn.Title = "Compte Name";
        compteCellCombo.Editable = true;

我试图在互联网上搜索Gtk.CellRendererCombo属性,但没有发现任何有价值的东西,我尝试了其中的一些:

  • 文本
  • 文本栏
  • 模型
  • 可编辑

但似乎没有任何效果,至于它生成这种消息的“文本”属性:

(eAppGtk:2528): Gtk-WARNING **: gtkliststore.c:608: Unable to convert from GtkSharpValue to gchararray


(eAppGtk:2528): Gtk-WARNING **: gtkliststore.c:608: Unable to convert from gchararray to gint

非常感谢您对出了什么问题的深入了解,谢谢。

4

1 回答 1

0

What I thought should be attribute set by a string in the Gtk.TreeViewColumn.AddAttribute(cell, attribute, columnIndex), could be set by the C# Properties' fashion. The Column Index in this situation is the Property TextColumn.

The rest should speak for itself in the code below:

this.compteComboBox = new CompteComboBox(this.window.CompteManager, new ComboBox());

Gtk.TreeViewColumn compteColumn = new TreeViewColumn();
Gtk.CellRendererCombo compteCellCombo = new CellRendererCombo();
compteColumn.PackStart(compteCellCombo, true);
compteColumn.Title = "Compte Name";
compteCellCombo.TextColumn = 0;
compteCellCombo.Editable = true;
compteCellCombo.Edited += OnEdited;
compteCellCombo.HasEntry = true;
compteCellCombo.Model = this.compteComboBox.ComboBox.Model;
compteCellCombo.Text = this.compteComboBox.ComboBox.ActiveText;
于 2012-12-01T20:15:56.283 回答