我想问一下如何根据条目列的值检查列表视图中的复选框。
可悲的是,经过几个小时的谷歌,我无法找到适合该法案的解决方案。因为大多数似乎都是基于Windows Forms。
以下是当前代码:
SDVVersion.Text = SDVMMVersion;
SMAPIVersion.Text = SDVMMSettings.SmapiVersion;
// Createing columns
Gtk.TreeViewColumn CBColumn = new Gtk.TreeViewColumn();
CBColumn.Title = "Active";
Gtk.CellRendererText CBCell = new Gtk.CellRendererText();
CBColumn.PackStart(CBCell, true);
Gtk.TreeViewColumn NameColumn = new Gtk.TreeViewColumn();
NameColumn.Title = "Name";
Gtk.CellRendererText ModsNameCell = new Gtk.CellRendererText();
NameColumn.PackStart(ModsNameCell, true);
Gtk.TreeViewColumn AuthorColumn = new Gtk.TreeViewColumn();
AuthorColumn.Title = "Author";
Gtk.CellRendererText AuthorCell = new Gtk.CellRendererText();
AuthorColumn.PackStart(AuthorCell, true);
Gtk.TreeViewColumn VersionColumn = new Gtk.TreeViewColumn();
VersionColumn.Title = "Version";
Gtk.CellRendererText VersionCell = new Gtk.CellRendererText();
VersionColumn.PackStart(VersionCell, true);
Gtk.TreeViewColumn DescColumn = new Gtk.TreeViewColumn();
DescColumn.Title = "Description";
Gtk.CellRendererText DescCell = new Gtk.CellRendererText();
DescColumn.PackStart(DescCell, true);
// Add the columns to the TreeView
activeMods.AppendColumn(CBColumn);
activeMods.AppendColumn(NameColumn);
activeMods.AppendColumn(AuthorColumn);
activeMods.AppendColumn(VersionColumn);
activeMods.AppendColumn(DescColumn);
activeMods.Model = new ListStore(typeof(string), typeof(string), typeof(string), typeof(string), typeof(string));
// the column checkbox is created
Gtk.CellRendererToggle valueCb = new CellRendererToggle();
CBColumn.PackStart(valueCb, true);
CBColumn.AddAttribute(valueCb, "bool",0);
NameColumn.AddAttribute(ModsNameCell, "text", 1);
AuthorColumn.AddAttribute(AuthorCell, "text", 2);
VersionColumn.AddAttribute(VersionCell, "text", 3);
DescColumn.AddAttribute(DescCell, "text", 4);
}
internal void RefreshTreeView()
{
ModStore.Clear();
foreach (ModInfo Mod in Mods) // Mods = the modstore, modInfo mod = the json tempalte from where it is read
{
ModStore.AppendValues(Mod.IsActive.ToString(), Mod.Name, Mod.Author, Mod.Version);
if(Mod.IsActive == true)
//checkbox = checked
}
}
我将非常感谢代码示例本身的示例链接提供的任何帮助。
〜结城