I am trying to create a GUI with a property grid ( grid of name:value pairs )
The listbox widget seems to be the way to start. ( please correct me if something better is available )
The code ( below ) I have written compiles and runs. The initial name/value pairs show fine, but the attempt to change the value of the first item achieves nothing.
I have looked at several listbox examples, but cannot find a simple way to change a value in a listbox once initialized
int main()
{
using namespace nana;
// form to hold everything
form fm;
// listbox to be the property grid
listbox lb(fm, nana::rectangle(10, 10, 280, 120));
// column headers
lb.append_header("Name", 200);
lb.append_header("Value", 200);
// add two items to the default category
lb.at(0).append({"A", "0"});
lb.at(0).append({"B", "0"});
// change value of A item to 32 ( fails to do anything )
lb.at(listbox::index_pair(0,1)).value("32");
fm.show();
exec();
}
Also tried ( doesn't compile )
lb.at(listbox::index_pair(0,1)).value({"A","32"});
and ( runs, has no effect )
lb.anyobj(0, 0, "32");
You are using very low level functions. There are more convenient higth level functions to set/change the values/text/items in the listbox (using STL containers or resolvers).
Assuming you want to use these low level function becouse you want to implement your own higth level API, here are some facts:
The
valuefunction of theitem_proxyyou are accesing withat(index_pair) will give you acces to some object you have previusly attached to that item. You have not attached any object. You may effectively first attach, an object or you may continue to work directly with the text. The simplest "hack" is to use the function text:lb.at(listbox::index_pair(0,1)).text(1,"32"), which set the text for the column 1 of that item.EDIT: A relatively simple to understand explanation: 3-methods-to-insert-data-into-listbox