|
|
Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » Why SetCtrl() places controls in first row of ArrayCtrl?
|
Re: Why SetCtrl() places controls in first row of ArrayCtrl? [message #61757 is a reply to message #61756] |
Tue, 29 July 2025 10:04   |
Oblivion
Messages: 1223 Registered: August 2007
|
Senior Contributor |
|
|
Hello lmonda,
Welcome to U++ forums!
Is there a specific reason why you use SetCtrl? The traditional way in U++ is as follows:
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
struct MyApp : TopWindow {
ArrayCtrl list;
MyApp()
{
Sizeable().Zoomable().CenterScreen().SetRect(0, 0, 800, 600);
Add(list.SizePos());
list.AddColumn("Column1").Ctrls([this](int i, One<Ctrl>& ctrl) {
ctrl.Create<Option>().SetLabel("Option " + AsString(i));
});
list.AddColumn("Column2").Ctrls([this](int i, One<Ctrl>& ctrl) {
ctrl.Create<Button>().SetLabel("Button " + AsString(i));
});
for(int i = 0; i < 10; i++)
list.Add();
}
};
GUI_APP_MAIN
{
MyApp().Run();
}
Note that this is more flexible and simple because:
1) You don't need to manage options separately. They are handled by the ArrayCtrl.
2) You can create any type of Ctrl per column AND row index.
Above code will result in this:

I also suggest you play with the reference examples and read the API doc of ArrayCtrl. It is comprehensive.
Best regards,
Oblivion
Github page: https://github.com/ismail-yilmaz
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Tue, 29 July 2025 11:16] Report message to a moderator
|
|
|
|
|
|
Re: Why SetCtrl() places controls in first row of ArrayCtrl? [message #61769 is a reply to message #61764] |
Tue, 05 August 2025 06:42   |
lmonda
Messages: 6 Registered: March 2025 Location: USA
|
Promising Member |
|
|
Hi Oblivion,
Thanks for your help so far.
I did more debugging in my migration project where it was crashing, i think it has do with editstring control that is part of the array ctrl.
I have a array ctrl with 7 columns that has various controls,like editstrig, droplist, doubleedit and options etc.
I have a error msg in the array ctrl second column that i am not sure what it means.
Please help me identify the error? Also row 0 is missing controls and it it empty. why? how to fix.
P.S this similar code works great in older upp versions.
I have put together a simple example of what error i am seeing at the moment and it is attached.
Thanks
Lmonda

[Updated on: Tue, 05 August 2025 06:44] Report message to a moderator
|
|
|
Re: Why SetCtrl() places controls in first row of ArrayCtrl? [message #61770 is a reply to message #61769] |
Tue, 05 August 2025 07:33   |
Oblivion
Messages: 1223 Registered: August 2007
|
Senior Contributor |
|
|
Hello LMonda,
This code works well (other parts seem redundant here, but feel free to re-add):
App() {
// Since you are using qtf in headers, '=' means center aligned text
a.AddColumn(t_("\1[@W=* #"));
a.AddColumn(t_("\1[@W=* Step Description")).Ctrls<EditString>(); // <- Was missing a space, hence the error...
a.AddColumn(t_("\1[@W=* Timed")).Ctrls<Option >();
a.AddColumn(t_("\1[@W=* Time(sec)")).Ctrls<EditDoubleSpin>();
a.AddColumn(t_("\1[@W=* Step Type")).Ctrls<DropList>();
a.AddColumn(t_("\1[@W=* Leak")).Ctrls<DropList>();
a.AddColumn(t_("\1[@W=* Filter(sec)")).Ctrls<EditDoubleSpin>();
for(int row =0; row< 63; row++)
a.Add(row, "test", true, 1.234);
a.SetLineCy(Draw::GetStdFontCy() + 8);
Add(a.SizePos());
Sizeable();
}
Best regards,
Oblivion
Github page: https://github.com/ismail-yilmaz
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Tue, 05 August 2025 10:33] Report message to a moderator
|
|
|
|
|
Goto Forum:
Current Time: Mon Aug 11 23:29:36 CEST 2025
Total time taken to generate the page: 0.07438 seconds
|
|
|