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 » Why SetCtrl() places controls in first row of ArrayCtrl?
Why SetCtrl() places controls in first row of ArrayCtrl? [message #61756] Tue, 29 July 2025 06:31 Go to next message
lmonda is currently offline  lmonda
Messages: 6
Registered: March 2025
Location: USA
Promising Member
If I am adding controls to the ArrayCtrl to multiple rows, I was hoping for them to be visible in multiple rows.
But I find them all placed in first row (index 0) on top of each other. Why ? Not understanding.
See code below and picture attached.
UPP version - 17490.


ArrayCtrl a;
a.AddColumn("column1");
a.AddColumn("column2");
for(int i=0;i<5;i++)
{
a.Insert(i);
a.SetCtrl(i,0,option.Add(),True);
a.CreateCtrl<Button>(i,1);
}

index.php?t=getfile&id=7102&private=0
index.php?t=getfile&id=7101&private=0
Re: Why SetCtrl() places controls in first row of ArrayCtrl? [message #61757 is a reply to message #61756] Tue, 29 July 2025 10:04 Go to previous messageGo to next message
Oblivion is currently offline  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:

index.php?t=getfile&id=7103&private=0

I also suggest you play with the reference examples and read the API doc of ArrayCtrl. It is comprehensive.


Best regards,
Oblivion


[Updated on: Tue, 29 July 2025 11:16]

Report message to a moderator

Re: Why SetCtrl() places controls in first row of ArrayCtrl? [message #61762 is a reply to message #61757] Thu, 31 July 2025 05:32 Go to previous messageGo to next message
lmonda is currently offline  lmonda
Messages: 6
Registered: March 2025
Location: USA
Promising Member
Hi Oblivion,

Thank you. I am migrating an older application that was started with Upp2007. This application uses Several Array ctrl to place custom widgets using SetCtrl() and later uses GetCtrl() to access the widgets. This application was previously migrated back in 2015, at that time we did not see any issue.
But now with latest UPP I have all the screens that uses setctrl() crashes.

Let me try adding the controls like you did and see if it fixes. I would still use GetCtrl() to access the individual controls though.

Thanks n Appreciate.
LMonda
Re: Why SetCtrl() places controls in first row of ArrayCtrl? [message #61763 is a reply to message #61762] Thu, 31 July 2025 18:04 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1223
Registered: August 2007
Senior Contributor
Hello LMonda,

Your code above also works here (on U++ nightly):

index.php?t=getfile&id=7104&private=0


If you provide a minimal but complete example which replicates the problem, I can examine and test it here.

Best regards,
Oblivion


Re: Why SetCtrl() places controls in first row of ArrayCtrl? [message #61764 is a reply to message #61763] Fri, 01 August 2025 06:27 Go to previous messageGo to next message
lmonda is currently offline  lmonda
Messages: 6
Registered: March 2025
Location: USA
Promising Member
Hi Oblivion,
I am not using nightly build, but version 17490 built on jan 20 2025.
I used one of the reference project, made simple changes. Attached the project here ArrayCtrlSetCtrl.zip
When i run this project attached, i see this screen attached.

Can you run and check this attached project.

Thanks
LMonda

index.php?t=getfile&id=7105&private=0
Re: Why SetCtrl() places controls in first row of ArrayCtrl? [message #61769 is a reply to message #61764] Tue, 05 August 2025 06:42 Go to previous messageGo to next message
lmonda is currently offline  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

index.php?t=getfile&id=7107&private=0

[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 Go to previous messageGo to next message
Oblivion is currently offline  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


[Updated on: Tue, 05 August 2025 10:33]

Report message to a moderator

Re: Why SetCtrl() places controls in first row of ArrayCtrl? [message #61771 is a reply to message #61769] Thu, 07 August 2025 02:36 Go to previous messageGo to next message
lmonda is currently offline  lmonda
Messages: 6
Registered: March 2025
Location: USA
Promising Member
Hi Oblivion
Thank you for pointing out the space.
I think the setctrl() calls are causing the first row to be blank. and that leads to the crash eventually.
I am trying to see if i can avoid doing setctrl() after adding the row.
But i still need to use getctrl() to access the controls. Will try to implement this and see if that fixes the issues.
Thanks
Lmonda
Re: Why SetCtrl() places controls in first row of ArrayCtrl? [message #61772 is a reply to message #61771] Thu, 07 August 2025 09:41 Go to previous message
Oblivion is currently offline  Oblivion
Messages: 1223
Registered: August 2007
Senior Contributor
Quote:

I think the setctrl() calls are causing the first row to be blank. and that leads to the crash eventually.
I am trying to see if i can avoid doing setctrl() after adding the row.
But i still need to use getctrl() to access the controls. Will try to implement this and see if that fixes the issues.


Interestingly, I don't get any blank first row. Even with the example you provided. (Tested on Win10/11, Linux/Gnome)


Best regards,
Oblivion


[Updated on: Thu, 07 August 2025 09:44]

Report message to a moderator

Previous Topic: ArrayCtrl - GetCtrl() function question
Goto Forum:
  


Current Time: Mon Aug 11 23:32:23 CEST 2025

Total time taken to generate the page: 0.05217 seconds