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 and background color of a row
Re: GridCtrl and background color of a row [message #41931 is a reply to message #41918] Fri, 07 February 2014 14:56 Go to previous message
deep is currently offline  deep
Messages: 263
Registered: July 2011
Location: Bangalore
Experienced Member
Hi

This is modified Grid01 from tutorial.
WhenCtrlsAction callback can be changed as required.

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

using namespace Upp;

struct App : TopWindow {
	typedef App CLASSNAME;

	GridCtrl grid;
	EditString name;
	EditInt age;
	Option opt1;

	App() {
		Sizeable().Zoomable();

		Add ( grid.SizePos() );

		grid.AddColumn ( "Name" ).Edit ( name );
		grid.AddColumn ( "Age" ).Edit ( age );

		grid.AddColumn ( "Status", t_ ( "Status" ), 4 ).Ctrls<Option>();

		grid.Add ( "Ann", 21 )
		.Add ( "Jack", 34 )
		.Add ( "David", 15 );
		grid.Add ( "Ann", 21 )
		.Add ( "Jack", 34 )
		.Add ( "David", 15 );
		grid.Add ( "Ann", 21 )
		.Add ( "Jack", 34 )
		.Add ( "David", 15 );
		grid.Add ( "Ann", 21 )
		.Add ( "Jack", 34 )
		.Add ( "David", 15 );

		grid.Set ( 5, 0, "Daniel" );
		grid.SetFixed ( 0, 1, "Age of person" );

		grid.Indicator();
		grid.WhenLeftDouble = THISBACK ( ShowInfo );

		grid.WhenCtrlsAction = THISBACK ( SetColor );  // call back for control change

		grid.ColorRows();
		grid.EditCell();
		grid.EnterLikeTab();
		grid.GoBegin();

	}


	void ShowInfo() {
		PromptOK ( Format ( "%s is %d years old", grid ( 0 ), grid ( 1 ) ) );
	}

	void SetColor() {
		int row = grid.GetRowId();
		if ( grid.Get ( row, 2 ) == 1 ) {  // check if opt is set
			grid.GetRow ( row ).Bg ( LtGreen() );
		}
		else {
			grid.GetRow ( row ).Bg ( Yellow() );
		}

	}
};

GUI_APP_MAIN {
	App().Run();
}



Warm Regards

Deepak

[Updated on: Sat, 08 February 2014 13:18]

Report message to a moderator

 
Read Message
Read Message
Previous Topic: AddColumn(0, ...) crashes
Next Topic: Icon + text inside ArrayCtrl cell
Goto Forum:
  


Current Time: Mon May 06 04:57:58 CEST 2024

Total time taken to generate the page: 0.02133 seconds