Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » SetDisplay, which works for column why not for cells ??
SetDisplay, which works for column why not for cells ?? [message #37760] |
Sat, 10 November 2012 05:55 |
ayana
Messages: 16 Registered: November 2011
|
Promising Member |
|
|
Hey all,
Referring to the "HomeBudget" program, the SetDisplay function works for column, in the same way it should be possible to set a display background color for particular cell in a column.
So Please let me know, how to set it for a particular cell in a grid.
|
|
|
Re: SetDisplay, which works for column why not for cells ?? [message #37851 is a reply to message #37760] |
Sun, 18 November 2012 12:07 |
|
deep
Messages: 263 Registered: July 2011 Location: Bangalore
|
Experienced Member |
|
|
Hello All,
I want to use GridCtrl::SetDisplay Function to set display for cell.
This is modified example from tutorial.
What should be correct syntax for SetDisplay to a cell?
#include <CtrlLib/CtrlLib.h>
#include <GridCtrl/GridCtrl.h>
using namespace Upp;
struct DispPM : GridDisplay {
virtual void Paint ( Draw &w, int x, int y, int cx, int cy, const Value &val, dword style,
Color &fg, Color &bg, Font &fnt, bool found, int fs, int fe ) {
if ( !val.IsNull() ) {
String Val = String ( val );
if ( Val == "Jack" ) {
fg = Blue();
fnt = fnt.Bold();
} else fg = Red();
}
GridDisplay::Paint ( w, x, y, cx, cy, val, style, fg, bg, fnt, found, fs, fe );
}
};
struct App : TopWindow
{
typedef App CLASSNAME;
GridCtrl grid;
EditString name;
EditInt age;
App()
{
Sizeable().Zoomable();
Add(grid.SizePos());
// grid.AddColumn("Name").Edit(name).SetDisplay(Single<DispPM>());
grid.AddColumn("Name").Edit(name);
grid.AddColumn("Age").Edit(age);
for ( int i=0; i<10; i++) {
grid.Add("Ann", 21)
.Add("Jack", 34)
.Add("David", 15);
}
grid.Set(0, 0, "Daniel");
grid.SetFixed(0, 1, "Age of person");
grid.Indicator();
grid.WhenLeftDouble = THISBACK(ShowInfo);
grid.SetDisplay(5,0,Single<DispPM>());
/* uncomment this to get random color of rows */
//grid.WhenChangeRow = THISBACK(SetRandomColor);
grid.ColorRows();
grid.EditCell();
grid.EnterLikeTab();
grid.GoBegin();
}
void ShowInfo()
{
PromptOK(Format("%s is %d years old", grid(0), grid(1)));
}
void SetRandomColor()
{
grid.GetRow().Bg(Color(rand() % 255, rand() % 255, rand() % 255));
}
};
GUI_APP_MAIN
{
App().Run();
}
This works as expected when I set display to Column during AddColumn call.
When I set display to particular cell I get following error during compilation.
main.cpp
Grid01: 1 file(s) built in (0:06.33), 6333 msecs / file, duration = 6349 msecs, parallelization 0%
Linking...
main.obj : error LNK2001:
unresolved external symbol "public: void __thiscall Upp::GridCtrl::SetDisplay(int,int,class Upp::GridDisplay &)" (?SetDisplay@GridCtrl@Upp" target="_blank">>@Upp@@QAEXHHAAVGridDisplay@2" target="_blank">>@2@@Z)
C:\DevTools\upp4193\out\tutorial\MSC10.Debug.Debug_Full.Gui\ Grid01.exe : fatal error LNK1120: 1 unresolved externals
Warm Regards
Deepak
|
|
|
Goto Forum:
Current Time: Fri Mar 29 07:56:00 CET 2024
Total time taken to generate the page: 0.01506 seconds
|