【问题标题】:gtk# CellRendererCombo in TreeViewgtk# 在 TreeView 中的 CellRendererCombo
【发布时间】:2012-11-19 15:54:45
【问题描述】:

我想要一个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

如果您能深入了解问题所在,我们将不胜感激,谢谢。

【问题讨论】:

    标签: c# grid gtk# gtktreeview cellrenderer


    【解决方案1】:

    我认为应该是Gtk.TreeViewColumn.AddAttribute(cell, attribute, columnIndex) 中的字符串设置的属性,可以通过C# 属性的方式设置。这种情况下的 Column Index 是 Property TextColumn。

    其余的应该在下面的代码中说明:

    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-09-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多