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 |
|
forlano
Messages: 1185 Registered: March 2006 Location: Italy
|
Senior 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 218 times)
|
|
|
|
Goto Forum:
Current Time: Thu May 16 18:49:56 CEST 2024
Total time taken to generate the page: 0.02360 seconds
|