1
我有以下問題, 我創建了一個樹模型與如下因素的論點:與列表同步一個GTK iterTree
this.Mods = SDVMMR.ModListManagment.LoadList(ModStore);
// 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);
// Add the columns to the TreeView
activeMods.AppendColumn(CBColumn);
activeMods.AppendColumn(NameColumn);
activeMods.AppendColumn(AuthorColumn);
activeMods.AppendColumn(VersionColumn);
NameColumn.AddAttribute(ModsNameCell, "text", 1);
AuthorColumn.AddAttribute(AuthorCell, "text", 2);
VersionColumn.AddAttribute(VersionCell, "text",3);
// the column checkbox is created
Gtk.CellRendererToggle valueCb = new CellRendererToggle();
CBColumn.PackStart(valueCb, true);
activeMods.Model = ModStore;
的代碼中使用MODS由內部定義的: 內部列表MODS的= new List();
富勒這裏refrence使用的modinfo命令:
public string Name { get; set; }
public string Author { get; set; }
public string Version { get; set; }
public string UniqueID { get; set; }
public string MinimumApiVersion { get; set; }
public string Description { get; set; }
public string EntryDll { get; set;}
public bool IsActive { get; set; }
public bool IsXnb { get; set; }
public string OrgXnbPath { get; set; }
我目前使用的函數看起來像:
internal static void addToTree(ModInfo Mod, ListStore ModStore)
{
/*Gtk.TreeIter iter = ModStore.AppendValues(Mod.Name);
ModStore.AppendValues(iter, "Author", Mod.Author);
ModStore.AppendValues(iter, "Version", Mod.Version);
ModStore.AppendValues(iter, "Description", Mod.Description);
ModStore.AppendValues(iter, "Is Active", Mod.IsActive.ToString());*/
ModStore.AppendValues(Mod.IsActive.ToString(),Mod.Name,Mod.Author,Mod.Version);
}
,但這個犯規接受列表條目。那麼有沒有辦法讓它也接受內存列表。
我自己有點工作,但需要第二個函數來解析應用程序啓動時加載的列表到treeview(liststore)中。 – yuuki
這應該與提到的foreach循環 –
悲傷不會被編譯接受,因爲「錯誤CS0230:類型和標識符都需要在foreach語句(CS0230)(SDVMMR)」 – yuuki