U++ framework
Do not panic. Ask here before giving up.

Home » Community » Newbie corner » Insert Button into GridCtrl Cell (Can you insert buttons (or any widgets) into gridCtrl?)
Re: Insert Button into GridCtrl Cell [message #59700 is a reply to message #59699] Thu, 09 March 2023 21:09 Go to previous messageGo to previous message
Oblivion is currently offline  Oblivion
Messages: 1264
Registered: August 2007
Senior Contributor
Hi,

For ArrayCtrl, you can add buttons and other ctrls. In fact, you can add different ctrls for each row of a given column. All you need to do is use the factory methods and setup a callback:

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

struct MyApp : TopWindow {
	ArrayCtrl list;

	MyApp()
	{
		Sizeable().Zoomable().CenterScreen().SetRect(0, 0, 1024, 800);
		Add(list.SizePos());
		auto sButtonFactory = [this] (int i, One<Ctrl>& c)
		{
			String s = list.Get(i, 0);
			c.Create<Button>()
				.SetLabel(s)
				.WhenAction = [s] { PromptOK("The value is " + s); };
		};
		
		list.AddColumn("texts");
		list.AddColumn("buttons").Ctrls(sButtonFactory);
		for(int i = 0; i < 100; i++)
			list.Add(AsString(100 - i), AsString(i));
		
	}
};

GUI_APP_MAIN
{
	MyApp().Run();
}



Same thing can be done with GridCtrl...

Best regards,
Oblivion


[Updated on: Thu, 09 March 2023 21:39]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Choose valid characters for EditString/EditField
Next Topic: Website build
Goto Forum:
  


Current Time: Sun Apr 26 12:04:47 GMT+2 2026

Total time taken to generate the page: 0.00588 seconds