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 » [SOLVED] How to load an array added to an TabCtrl?
[SOLVED] How to load an array added to an TabCtrl? [message #47729] Sun, 12 March 2017 19:14 Go to next message
Patisab is currently offline  Patisab
Messages: 21
Registered: December 2015
Location: France
Promising Member
Good evening,

I would like to load an array which is added to a TabCtrl. The TabCtrl is declared in a Layout. I have something like this :

pbeTest.h
#ifndef _pbeTest_pbeTest_h
#define _pbeTest_pbeTest_h

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

#define LAYOUTFILE <pbeTest/pbeTest.lay>
#include <CtrlCore/lay.h>

class pbeTest : public WithpbeTestLayout<TopWindow> {
public:
	typedef pbeTest CLASSNAME;
	
	void fTest1();
	
	pbeTest();
};

class Test1 : public WithTest1Layout<TopWindow> {
public:
	typedef Test1 CLASSNAME;
	Test1(){
		CtrlLayoutOK(*this, "Window title");
		WithGridLayout<ParentCtrl> Grid;
		CtrlLayout(Grid);
		tb.Add(Grid.SizePos(),"Tableau");
		Grid.arr.SizePos();
		
		Grid.arr.AddRowNumColumn();
		Grid.arr.AddColumn("Colonne 1").Sorting();
		Grid.arr.AddColumn("Colonne 2").Sorting();
		
		alim <<= THISBACK(fAlim);
	}
	void fAlim();
};

#endif


main.cpp
#include "pbeTest.h"

void pbeTest::fTest1()
{
	Test1 dlg;
	if(dlg.Run() != IDOK)
	return;
}

pbeTest::pbeTest()
{
	CtrlLayout(*this, "Window title");
	
	test <<= THISBACK(fTest1);
	ok <<= THISBACK(Close);
}

GUI_APP_MAIN
{
	pbeTest().Run();
}


Test1.cpp
#include "pbeTest.h"

void Test1::fAlim()
{
	for(int i =0 ; i < 5 ; i++)
	{
		Grid.arr.Add("C1L" + AsString(Format("%d",i)),"C2L" + AsString(Format("%d",i)));
	}
}


pbeTest.lay
LAYOUT(pbeTestLayout, 200, 100)
	ITEM(Button, ok, SetLabel(t_("Quitter")).LeftPosZ(72, 56).TopPosZ(76, 15))
	ITEM(Button, test, SetLabel(t_("Test1")).LeftPosZ(72, 56).TopPosZ(12, 15))
END_LAYOUT

LAYOUT(Test1Layout, 400, 200)
	ITEM(Button, ok, SetLabel(t_("Sortir")).LeftPosZ(64, 56).TopPosZ(180, 15))
	ITEM(TabCtrl, tb, LeftPosZ(4, 392).TopPosZ(4, 172))
	ITEM(Button, alim, SetLabel(t_("Charger")).LeftPosZ(4, 56).TopPosZ(180, 15))
END_LAYOUT

LAYOUT(GridLayout, 400, 200)
	ITEM(ArrayCtrl, arr, LeftPosZ(4, 392).TopPosZ(4, 192))
END_LAYOUT



When i compile i obtain an error message :

pbeTest/Test1.cpp:7: error: 'Grid' was not declared in this scope.
Grid.arr.Add("C1L" + AsString(Format("%d",i)),"C2L" + AsString(Format("%d",i)));

I have probably forget something but i don't see what.

Thank very much for your help.

Best regards.

[Updated on: Wed, 12 September 2018 14:15]

Report message to a moderator

Re: How to load an array added to an TabCtrl? [message #47730 is a reply to message #47729] Sun, 12 March 2017 19:29 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1092
Registered: August 2007
Senior Contributor
Hello,

You seem to declare Grid locally in the constructor. Therefore it will be out of scope (won't be available). Try to make it a member.



class Test1 : public WithTest1Layout<TopWindow> {

WithGridLayout<ParentCtrl> Grid;                                           // <------ Grid should be declared here, or elswhere 
                                                                           //         so that it can be reached within the Test1 class.

public:
	typedef Test1 CLASSNAME;
	Test1(){
		CtrlLayoutOK(*this, "Window title");
		WithGridLayout<ParentCtrl> Grid;                            // <------ Grid is declared locally in constructor (The reason of the error.). 
		CtrlLayout(Grid);                                           
		tb.Add(Grid.SizePos(),"Tableau");
		Grid.arr.SizePos();
		
		Grid.arr.AddRowNumColumn();
		Grid.arr.AddColumn("Colonne 1").Sorting();
		Grid.arr.AddColumn("Colonne 2").Sorting();
		
		alim <<= THISBACK(fAlim);
	}
	void fAlim();
};





Regards,

Oblivion


[Updated on: Sun, 12 March 2017 19:35]

Report message to a moderator

Re: How to load an array added to an TabCtrl? [message #47731 is a reply to message #47730] Sun, 12 March 2017 20:04 Go to previous message
Patisab is currently offline  Patisab
Messages: 21
Registered: December 2015
Location: France
Promising Member
Thank you very much Oblivion. It's good now.

I thought that i have to declare Grid in the constructor to be used. I suppose the line CtrlLayout(Grid); in constructor make the call to Grid. Is it right?

Best regards.
Previous Topic: Reading from .txt and putting data (double) in array[]
Next Topic: GridCtrl mouse click problem (Closed)
Goto Forum:
  


Current Time: Sat Apr 20 13:05:35 CEST 2024

Total time taken to generate the page: 0.03863 seconds