Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » ColumnList - Set(Value key, Value val) - Working right?
ColumnList - Set(Value key, Value val) - Working right? [message #28190] Sat, 21 August 2010 16:55 Go to next message
jeremy_c is currently offline  jeremy_c
Messages: 175
Registered: August 2007
Location: Ohio, USA
Experienced Member
I have the following code:

Value id = codelist.GetData();
codelist.Set(id, "Hello World!")


It does not change the selected item. Instead it seems to be changing the item at an index of "id".

This code works as expected:

int idx = codelist.Find(id);
codelist.Set(idx, ~d.value);


From Assist++ it seems that .Set(Value key, Value val) should set it based on key, thus the first example should have worked?

Jeremy
Re: ColumnList - Set(Value key, Value val) - Working right? [message #29161 is a reply to message #28190] Fri, 08 October 2010 09:27 Go to previous messageGo to next message
bonami is currently offline  bonami
Messages: 186
Registered: June 2007
Location: Beijing
Experienced Member
columnlist is like a map. a key is the data's identifier not its index.
use SetIndex(index) to change current item displayed.
Re: ColumnList - Set(Value key, Value val) - Working right? [message #29163 is a reply to message #29161] Fri, 08 October 2010 11:16 Go to previous message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
It's a very small bug. See the definition of the Set functions:
    void         Set(int ii, const Value& key, const Value& val, bool canselect = true);
    void         Set(int ii, const Value& key, const Value& val, const Display& display, bool canselect = true);
    void         Set(int ii, const Value& val, bool canselect = true);
    void         Set(int ii, const Value& val, const Display& display, bool canselect = true);

    void         Set(const Value& key, const Value& val, const Display& display, bool canselect);
    void         Set(const Value& key, const Value& val, bool canselect);

You are intending to call Set(Value, Value) but there is no candiate for that, the closest being Set(Value, Value, bool). As there is an implicit declared from Value to int the compiler is actually choosing Set(int, Value), which sets the value using an index.

The quick solution is to add the canselect parameter to your call:
Value id = codelist.GetData();
codelist.Set(id, "Hello World!", true);

but the function definition should also be changed to have a default value.
Previous Topic: Window move virtual function
Next Topic: VC10 not recognized in autosetup
Goto Forum:
  


Current Time: Fri Mar 29 09:10:23 CET 2024

Total time taken to generate the page: 0.02096 seconds