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 » ArrayCtrl, HeaderCtrl & GridCtrl » how to set/get data in a composite embedded ctrl in an arrayctrl
Re: how to set/get data in a composite embedded ctrl in an arrayctrl [message #3082 is a reply to message #3076] Sat, 06 May 2006 07:02 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14264
Registered: November 2005
Ultimate Member
forlano wrote on Fri, 05 May 2006 20:06

Hello,

here is a new variant of a code already posted in this forum. We have an arrayctrl with two column of which the second one contains a composite embedded ctrl (editint+label). The click on the button start the scan of the rows to get their value.
I would like to get some hint for the followomg tasks:
1. how to GET the data of editint in row 'i' ;
2. how to SET the data of editint in row 'i' ;

I am able to perform this task in case of a single control in the cell but with two in the cell I'm lost Smile .
Thank you
Luigi

#include <CtrlLib/CtrlLib.h>

#define LAYOUTFILE    <edithelp/a.lay>
#include <CtrlCore/lay.h>

//--------------------- begin class -----------------
class EditLabel : public WithEditLabel<TopWindow> {
public:
	typedef EditLabel CLASSNAME;
	void WriteLabel();
	EditLabel();
};

void EditLabel::WriteLabel()
{	lbl.SetLabel( AsString(~edit) );
	SetFocus();
}

EditLabel::EditLabel()
{	CtrlLayout(*this, "");
	edit <<= THISBACK(WriteLabel);
}

void Extra2(One<Ctrl>& ctrl)
{	ctrl.Create<EditLabel>();
}
//--------------------- end class -------------------

ArrayCtrl arr;
void getvaluearray()
{ for(int i=0; i<arr.GetCount(); i++)
  { Exclamation( AsString ( arr.Get(i, 0) ) ); // get data in column 0
    // how to get the editint value in column 1?
  }
	
}
GUI_APP_MAIN
{
	TopWindow w;

	Button btn;
	
	arr.AddColumn("col1",20);
	arr.AddColumn("col2",20).Ctrls(Extra2);
	arr.SetLineCy(20);
		
	arr.Add("aaa");
	arr.Add("bbb");
	arr.Add("ccc");
	arr.SizePos();
	w.Add(arr);
	w.Add(btn);
	btn.SetLabel("Get data").LeftPosZ(72, 116).TopPosZ(292, 20);
	btn.WhenAction = callback(getvaluearray);
	w.Run();
}

LAYOUT(EditLabel, 96, 19)
	ITEM(EditInt, edit, LeftPosZ(2, 32).TopPosZ(1, 17))
	ITEM(Label, lbl, SetFrame(ThinInsetFrame()).LeftPosZ(36, 60).TopPosZ(1, 17))
END_LAYOUT



Hopefuly, despite Aris' despect, this time U++ is ortogonal:

To get/set Value, you use "SetData"/"GetData". The same applies to composite Ctrl, just in this case you will need more than single Value. The solution is ValueArray which can pack more Values into single value. Therefore:

void MyCompositeCtrl::SetData(const Value& v)
{
   ValueArray va = v;
   myintedit <<= va[0];
   mytextedit <<= va[1];
....
}

....
ValueArray va;
va.Add(1);
va.Add("Hello");
arrayctrl.Set(1, 1, va);



Mirek
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: ArrayCtrl cell consisting of edit and helper button
Next Topic: ArrayCtrl cell color
Goto Forum:
  


Current Time: Thu Jul 03 02:58:03 CEST 2025

Total time taken to generate the page: 0.03666 seconds