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 » GridCtrl: how to set label of an Option
GridCtrl: how to set label of an Option [message #35936] Fri, 06 April 2012 08:22 Go to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
Hello,

I have a GridCtrl with many Option created by
    gridTeam.AddColumn("W", "Team 1", 3).Option().Default(false); 
    gridTeam.AddColumn("B", "Team 2", 3).Option().Default(false); 
    for (i=0; i<TD.MaxBoards; i++) gridTeam.Add(i+1); 


I can easily set the option true/false with
gridTeam.Set(j, 1, true);

But I need to set at runtime the label of the Option. It has the SetLabel() method but I am not able to do it in the cell of the grid. How to do it?

Thanks,
Luigi
Re: GridCtrl: how to set label of an Option [message #35937 is a reply to message #35936] Fri, 06 April 2012 12:08 Go to previous message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
Perhaps I must do something like this using SetCtrl

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

using namespace Upp;

struct App : TopWindow {
	Array<Option> option;
	GridCtrl grid;
	
	void Do()
	{   int row = grid.GetCurrentRow();
        bool status = option[row].GetData();
		if (status) option[row].SetLabel("false");
		else option[row].SetLabel("true");
	}
	
	typedef App CLASSNAME;
	
	App() {
		grid.AddColumn("Option");
		for(int i = 0; i < 10; i++) {
			grid.Add(true);
			grid.SetCtrl(i, 0, option.Add().SetLabel("---"));			
		}
		Add(grid.SizePos());
		grid.WhenCtrlsAction = THISBACK(Do);
	}
};

GUI_APP_MAIN
{
	App().Run();
}
Previous Topic: Excessive memory use
Next Topic: Autosizing columns
Goto Forum:
  


Current Time: Fri Mar 29 12:12:27 CET 2024

Total time taken to generate the page: 0.02170 seconds