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 » How to get a Ctrl within ArrCtrl
How to get a Ctrl within ArrCtrl [message #61866] Sat, 22 November 2025 12:13 Go to next message
forlano is currently offline  forlano
Messages: 1217
Registered: March 2006
Location: Italy
Senior Contributor
Hello

I have added several buttons to an ArrayCtrl with this code

void TournamentTiebreakDlg::AddBtn(int row, int col, int idTB, String label) {
		Button& btn = gridtb.CreateCtrl<Button>(row,col);
		String l = label;

		btn.SetLabel(l);
		btn << [&,row,col,idTB] {
			SetTB(row, col, idTB);
		};
	}	


Now I need to get some of these buttons and disable them.
I am tryng stuff like this
Button& btn = panel.gridtb.GetCtrl(4,1);
but the compiler keep complaining all my temptives.
Which is the recommended way?

Thank you very much,
Luigi
Re: How to get a Ctrl within ArrCtrl [message #61867 is a reply to message #61866] Sat, 22 November 2025 16:29 Go to previous message
forlano is currently offline  forlano
Messages: 1217
Registered: March 2006
Location: Italy
Senior Contributor
This is the working solution from chatgpt

void DisableButton(int row, int col) {
Ctrl* ctrl = gridtb.GetCtrl(row, col);
if(!ctrl) return;

if(Button* b = dynamic_cast<Button*>(ctrl)) {
b->Disable();
}
}
It is amazing how many things it knows about U++. Sometimes it invents functions and method that does not exist.
Luigi
Previous Topic: Why SetCtrl() places controls in first row of ArrayCtrl?
Goto Forum:
  


Current Time: Sat Nov 22 16:54:13 CET 2025

Total time taken to generate the page: 0.08243 seconds