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 » Community » Newbie corner » Insert Button into GridCtrl Cell (Can you insert buttons (or any widgets) into gridCtrl?)
Re: Insert Button into GridCtrl Cell [message #59704 is a reply to message #59702] Fri, 10 March 2023 00:10 Go to previous message
Oblivion is currently offline  Oblivion
Messages: 1094
Registered: August 2007
Senior Contributor
Quote:
Now the problem is there is no explanation on how to change label or add functionality to individual buttons with the "MakeButton" method


There are several ways, a simple one:

#include <CtrlLib/CtrlLib.h>
#include <GridCtrl/GridCtrl.h>

using namespace Upp;

struct MyButton : Button {
	Value val;
	MyButton() : Button()
	{
		WhenAction = [this]
		{
			PromptOK("The value of the button is " + AsString(val));
		};
	}
	void SetData(const Value& v) override
	{
		SetLabel(AsString(val = v));
	}
	
	Value GetData() const override
	{
		return val;
	}
};

struct MyApp : TopWindow {
	GridCtrl  list;
	MyApp()
	{
		Sizeable().Zoomable().CenterScreen().SetRect(0, 0, 1024, 800);
		Add(list.SizePos());
		list.AddColumn("texts");
		list.AddColumn("buttons").Ctrls<MyButton>();
		for(int i = 0; i < 100; i++)
			list.Add(AsString(i), i * 1000);
	
		
	}
};

GUI_APP_MAIN
{
	MyApp().Run();
}




Best regards,
Oblivion


[Updated on: Fri, 10 March 2023 00:26]

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: Thu May 23 13:17:48 CEST 2024

Total time taken to generate the page: 0.00394 seconds