Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » AttrText() and content of the cell
|
Re: AttrText() and content of the cell [message #11947 is a reply to message #11933] |
Wed, 03 October 2007 15:46 |
|
forlano
Messages: 1185 Registered: March 2006 Location: Italy
|
Senior Contributor |
|
|
forlano wrote on Tue, 02 October 2007 21:59 |
From what I'm observing it seems that the content of the cell is not exactly the same. Maybe some invisible character is added by AttrText() that it is passed to display to paint the cell?
Thanks,
Luigi
|
It is as suspected
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
GUI_APP_MAIN
{ ArrayCtrl arr;
TopWindow w;
w.Add(arr);
arr.SizePos();
arr.AddColumn("col");
arr.AddColumn("two");
arr.Add( 1, 2);
arr.Add( 1, 2);
arr.Add( 1, 2);
arr.Set(2,1, AttrText("2").Paper(Color(250,150,150)) );
arr.Add( 1, arr.Get(2,1) ); //arr.Get(2,1) get not only the number "2" but even some info regarding the color of the cell
arr.Add( 1, arr.Get(2,1).ToString() ); //I can't get "2"
arr.Add( 1, AsString(arr.Get(2,1)) ); //I can't get "2"
w.Run();
}
Because AttrText() (both in arrayctrl and gridctrl) extend in some way the data I put inside the cell I would like to know how to extract the data previously inserted in the cell. I mean disregarding the color information and so on. In other words, if I put a number in the cell and then modify its appearence I would like to get back the same number if I need it.
Alternatively I would like to know how to set the background color of a cell indipendently of the content of the cell. If I use Display I can test the passed data, but sometimes would be very useful a direct way to change the background of the cell (i,j) irrispective of the value inside and in a way that it is determined only at runtime.
Luigi
[Updated on: Wed, 03 October 2007 15:48] Report message to a moderator
|
|
|
Re: AttrText() and content of the cell [message #11948 is a reply to message #11947] |
Wed, 03 October 2007 16:44 |
mrjt
Messages: 705 Registered: March 2007 Location: London
|
Contributor |
|
|
The ArrayCtrl is just returning exactly what you put in - an AttrText - but contained in a Value. You just need to convert it back, though this is more slightly more complicated than for Upp 'native' types:
WString GetText(const Value &v)
{
return IsTypeRaw<AttrText>(v) ? ValueTo<AttrText>(v).text : WString();
} James
[Updated on: Wed, 03 October 2007 16:46] Report message to a moderator
|
|
|
|
|
Goto Forum:
Current Time: Mon Apr 29 02:35:10 CEST 2024
Total time taken to generate the page: 0.06770 seconds
|