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 modify the cell content before to accept the row
GridCtrl: how to modify the cell content before to accept the row [message #43622] Mon, 15 September 2014 18:25 Go to previous message
forlano is currently offline  forlano
Messages: 1071
Registered: March 2006
Location: Italy
Experienced Contributor
Hello,

I have a question about GridCtrl with two embedded ctrls via .Edit().
I prepared a test case with a GridCtrl and two columns, each one contain an EditString. This is the code

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

using namespace Upp;

#define LAYOUTFILE <testgrid/testgrid.lay>
#include <CtrlCore/lay.h>

class testgrid : public WithtestgridLayout<TopWindow> {
EditString editName, editCountry;
public:
	typedef testgrid CLASSNAME;
	testgrid();
	void OnAcceptRow();
};


testgrid::testgrid()
{
	CtrlLayout(*this, "Window title");
	grid.AddColumn("Name", "Name", 12).Edit(editName);   
	grid.AddColumn("Country", "Country", 4).Edit(editCountry);    
	grid.WhenAcceptRow = THISBACK(OnAcceptRow);   
}

void testgrid::OnAcceptRow()
{   
    grid.CancelAccept();    
	if ( IsNull(AsString(~editName)) ) {
		Exclamation("The Name field cannot be empty!");
	    return ;
	}	
	if ( IsNull(AsString(~editCountry)) ) editCountry <<= "Mycountry";
    grid.cancel_accept=false;
}

GUI_APP_MAIN
{
	testgrid().Run();
}


I add a row by a mouse right click;
then enter a string in the first column and leave empty the second one;
then press ENTER.
This should trigger the OnAcceptRow callback. It correctly performs the check on editName but do not perform any action on editCountry that remain void. Instead I would like to avoid that editCountry reamain empty.
I do not want to use the .Default() method because the data to put in the grid may change at runtime.

What am I missing?

Thanks,
Luigi
  • Attachment: testgrid.rar
    (Size: 1.43KB, Downloaded 96 times)
 
Read Message
Read Message
Previous Topic: GridCtrl sorting
Next Topic: ArrayCtrl Drag&Drop
Goto Forum:
  


Current Time: Mon Dec 16 12:06:57 CET 2019

Total time taken to generate the page: 0.01013 seconds