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 » Community » Newbie corner » GridCtrl help needed
GridCtrl help needed [message #32650] Tue, 31 May 2011 13:28 Go to next message
bushman is currently offline  bushman
Messages: 134
Registered: February 2009
Experienced Member
Please, help me with the code below:

.h:
class Ma_app : public TopWindow {
	
public:
	typedef Ma_app CLASSNAME;
	Ma_app();
	
private:
	
	GridCtrl grid;
};


.cpp:

void CreateWidget(One<Ctrl>& ctrl)
{
	ctrl.Create<EditString>();
}

Ma_app::Ma_app()
{

	Zoomable().Sizeable();
			
	for(int col = 0; col < 10; col++)
		grid.AddColumn(Format("col %d", col)).Ctrls(CreateWidget);
	
	grid.Add();
	grid.GoBegin();
	for(int col = 0; col < 10; col++)
		grid.SetCtrlValue(col, "a string");
	
	Add(grid.SizePos());
}

GUI_APP_MAIN
{
	Ma_app().Run();
}


I expected GridCtrl Edits to display "a string", but got blank EditStrings instead. What am I doing wrong??

Help appreciated, thanks in advance.

[Updated on: Tue, 31 May 2011 13:30]

Report message to a moderator

Re: GridCtrl help needed [message #32651 is a reply to message #32650] Tue, 31 May 2011 14:10 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Hi!

SetCtrlValue doesn't work, because controls are not created yet. They will be created during window opening. To make it work in your case call SyncCtrls before setting control values:
	grid.Add();
            grid.SyncCtrls();
	grid.GoBegin();
	for(int col = 0; col < 10; col++)
		grid.SetCtrlValue(col, "a string");


But the simplest and the best way is to replace SetCtrlValue with Set. In proper time controls will be automatically populated with underlying grid values;

	grid.Add();
	grid.GoBegin();
	for(int col = 0; col < 10; col++)
		grid.Set(col, "a string");
Re: GridCtrl help needed [message #32653 is a reply to message #32651] Tue, 31 May 2011 16:55 Go to previous message
bushman is currently offline  bushman
Messages: 134
Registered: February 2009
Experienced Member
Thank you so much for your clarification!
It works fine now, once your recommendations were implemented. Anyway, how could I know? Thanks again!

By the way, since you are there, could you please take a look at the other post a couple messages below this same newbie section and provide me with a hint on how could I possibly restrict clicks to just one GridCtrl row? The post title is Restricting GridCtrl Selection to just One row [message #32622] (sorry, dont't know how to refer you to the msg directly by a link using this forum).

Once again, many thanks!
Previous Topic: How to internet enable a serial device
Next Topic: GridCtrl out-of-bound crash with test case
Goto Forum:
  


Current Time: Fri Apr 26 02:45:48 CEST 2024

Total time taken to generate the page: 0.04989 seconds