c# - Setting a NodeView to reflect the changes in the ListStore Model -
using mono
, monodevelop
, c#
, gtk#
on linux.
i know has been asked before, no matter try, none of examples or answers seem work me. still can't changes in liststore
reflected in treeview
.
i start of so....
liststore ls_nvdevicefiledescription = new liststore (typeof(string), typeof(string), typeof(string)); liststore ls_dev_sensor_codes = new liststore (typeof(string)); liststore ls_dev_sensor_value_types = new liststore (typeof(string));
the first liststore
treeview
, second , third cellrenderercombo
's on column 1 , 3 of treeview
.
i add values cellrenderercombo
's user pick values from....
string[] _codes = csql.csql_getdevicesensorcodes (); string[] _types = csql.csql_getdevicesensorvaluetypes (); // codes. if (_codes != null) { (int = 0; < _codes.length; i++) { ls_dev_sensor_codes.appendvalues (_codes [i]); } } //do types if (_types != null) { (int = 0; < _types.length; i++) { ls_dev_sensor_value_types.appendvalues (_types [i]); } }
i bind liststore
they're appropriate 2 cellrenderers
....
dev_sensor_codes.model = ls_dev_sensor_codes; dev_sensor_codes.textcolumn = 0; dev_sensor_value_types.model = ls_dev_sensor_value_types; dev_sensor_value_types.textcolumn = 0;
and of course pack them onto they're respective columns....
col_sensor_code.packstart (dev_sensor_codes, true); col_sensor_descr.packstart (dev_sensor_descr, true); col_sensor_value_type.packstart (dev_sensor_value_types, true);
i bind liststore
treeview
, append columns....
nvdevicefiledescr.model = ls_nvdevicefiledescription; nvdevicefiledescr.appendcolumn (col_sensor_code); nvdevicefiledescr.appendcolumn (col_sensor_descr); nvdevicefiledescr.appendcolumn (col_sensor_value_type);
i use following code append row treeview
(the change reflected).
liststore store = (liststore)nvdevicefiledescr.model; treeiter iter = store.append (); treepath path = store.getpath (iter); nvdevicefiledescr.setcursor (path, nvdevicefiledescr.columns[0], true);
now, i'll give 2 examples of edited events i'm sure should work, doesn't....
example 1:
dev_sensor_codes.edited += delegate(object o, editedargs args) { liststore store = (liststore)nvdevicefiledescr.model; treeselection sel = nvdevicefiledescr.selection; treeiter iter; if (!sel.getselected (out iter)) { return; } store.setvalue(iter, 1, args.newtext); };
example 2:
dev_sensor_value_types.edited += delegate(object o, editedargs args) { liststore store = (liststore)nvdevicefiledescr.model; treeiter iter; store.getiterfromstring(out iter, args.path); store.setvalue (iter, 2, args.newtext); };
in both examples know i'm using iter
, because gtk
has habit of letting know if have stale iter (i think?), , treepath
, must it's passed through edited args
.
i can verify right iters, paths , values printing stdout
, can't changes in liststore
treeview
reflected in treeview
.
the change show, when programatically appendvalues
, or append
. add new line in treeview
, no values ever show up.
many, many hand.
==========================================
solution
so, case, answer our own questions because neglect read our own code right?
i've left out crucial step in whole thing above , binding cellrenderers actual columns. 'looked' did, didn't, here goes....
i packed cellrenderers in columns following....
column.packstart (cellrenderer, bool); //or in case col_sensor_code.packstart (dev_sensor_codes, true);
this fine, need bind cellrenderer column (or other column actually) so......
column.addattribute (cellrenderer, attribute, column index); // in case instance.... col_sensor_code.addattribute (dev_sensor_codes, "text", 0);
so, many time , hope helps other blind fool ;)
Comments
Post a Comment