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   |
Oblivion
Messages: 1204 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
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Thu, 09 March 2023 21:39] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Mon Apr 28 13:44:23 CEST 2025
Total time taken to generate the page: 0.01041 seconds
|