Home » U++ Library support » U++ Widgets - General questions or Mixed problems » ArrayCtrl with labels / layouts inside ?
Re: ArrayCtrl with labels / layouts inside ? [message #12911 is a reply to message #12894] |
Tue, 27 November 2007 22:55   |
 |
mirek
Messages: 14261 Registered: November 2005
|
Ultimate Member |
|
|
jiaif wrote on Mon, 26 November 2007 13:18 | Thank you for the code, but i'm sorry, i have the same errors 
I don't understand why.
Maybe because myArray is added before i add buttons ?
I mean in my code, myArray is defined in the layout.
Maybe because i'm under linux ? 
[edit]
if i do :
Button b;
b.SetLabel("test");
myArray.AddColumn("test");
myArray.SetCtrl(0,0,&b);
it compile well but the button don't appear. Any idea ?
|
First of all, SetCtrl(..., Ctrl *ctrl);
is deprecated and should not be used in any new code, in fact, it will likely be removed.
Anyway, now I believe that the fundamental problem of your code is that you are doing something like:
MyApp::MyApp() {
Button b;
...
myArray.SetCtrl(0,0,b);
}
This cannot work (or in fact, works as expected), as Button is destroyed at the and of MyApp().
To make it more clear, have fun:
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
#define LAYOUTFILE <Test/Test.lay>
#include <CtrlCore/lay.h>
class ArrayTest : public WithArrayTestLayout<TopWindow> {
public:
typedef ArrayTest CLASSNAME;
ArrayTest();
Array<Button> btn;
Array<Option> opt;
};
ArrayTest::ArrayTest()
{
CtrlLayout(*this, "Window title");
Sizeable().Zoomable();
myArray.AddColumn("Column1");
myArray.AddColumn("Column2");
for(int i = 0; i < 100; i++) {
myArray.Add("Row: " + AsString(i + 1));
if(i & 1) {
Button& b = btn.Add();
b.SetLabel(Format("Button %d", i + 1));
myArray.SetCtrl(i, 1, b);
}
else {
Option& o = opt.Add();
o.SetLabel(Format("Option %d", i + 1));
myArray.SetCtrl(i, 1, o);
}
}
}
GUI_APP_MAIN
{
ArrayTest().Run();
}
Mirek
|
|
|
 |
|
ArrayCtrl with labels / layouts inside ?
By: jiaif on Sun, 25 November 2007 19:23
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: jiaif on Sun, 25 November 2007 19:49
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: mirek on Sun, 25 November 2007 21:24
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: jiaif on Sun, 25 November 2007 22:07
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: mirek on Mon, 26 November 2007 09:07
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: jiaif on Mon, 26 November 2007 17:03
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: Oblivion on Mon, 26 November 2007 18:06
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: jiaif on Mon, 26 November 2007 18:32
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: Oblivion on Mon, 26 November 2007 18:55
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: jiaif on Mon, 26 November 2007 19:18
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: Oblivion on Mon, 26 November 2007 20:07
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: jiaif on Mon, 26 November 2007 20:26
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: mirek on Mon, 26 November 2007 22:16
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: jiaif on Tue, 27 November 2007 00:28
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: jiaif on Tue, 27 November 2007 12:13
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: mrjt on Tue, 27 November 2007 12:52
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: jiaif on Tue, 27 November 2007 12:57
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: Oblivion on Tue, 27 November 2007 19:43
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: jiaif on Tue, 27 November 2007 21:36
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: Oblivion on Tue, 27 November 2007 22:10
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: mirek on Tue, 27 November 2007 22:57
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: jiaif on Wed, 28 November 2007 18:59
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: jiaif on Wed, 28 November 2007 19:24
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: Oblivion on Wed, 28 November 2007 22:27
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: mirek on Thu, 29 November 2007 05:49
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: mrjt on Thu, 29 November 2007 13:57
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: mirek on Tue, 04 December 2007 09:39
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: jiaif on Thu, 06 December 2007 18:25
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: jiaif on Thu, 06 December 2007 19:15
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: jiaif on Tue, 27 November 2007 12:54
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: mirek on Tue, 27 November 2007 22:55
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: Novo on Thu, 06 December 2007 20:29
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: waxblood on Fri, 07 December 2007 11:28
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: Novo on Fri, 07 December 2007 18:31
|
 |
|
Re: ArrayCtrl with labels / layouts inside ?
By: jiaif on Sat, 08 December 2007 00:56
|
Goto Forum:
Current Time: Sun Jun 08 20:46:11 CEST 2025
Total time taken to generate the page: 0.04341 seconds
|