|
hi,
you should prepare a cell with desired attributes ( text, back, htext, hback colors etc.) and use it as default grid cell.
or you can use individualy attributed cells for each column as well.
so when grid inserts a new row it uses default grid or col attributes.
take a look at SetGridDefault & SetColDefault in UG help.
CUGCell cell;
GetGridDefault(&cell);
cell.SetBackColor(RGB(255,255,255));
SetGridDefault(&cell);
or
GetColDefault(9 ,&cell);
cell.SetBackColor(RGB(255,255,255));
SetColDefault(9,&cell);
regards.
atilla.
|
|
|
|
|
Atilla,
thanks for the answer, but I am not sure yet.
Actually, the following code is to log events whenever one happens and I want to make the last row inserted in highlighted color to make it clearly visible among the old events.
//****** First add a new row for an event logging
int ans = m_grid1.InsertRow(0);
//****** Then set the back/text color and select the range to apply
cell.SetBackColor(RGB(0, 255, 255));
cell.SetTextColor(RGB(0, 0, 0));
m_grid1.QuickSetRange(0, 0, mr_grid1.GetNumberCols() - 1, 0, &cell);
//****** Next write the log
m_grid1.QuickSetText(0, 0, _T("T2"));
m_grid1.QuickSetText(1, 0, m_pOwner->m_AUTOBS); // AUTOBS##
m_grid1.QuickSetNumber(2, 0, ++m_pOwner->m_OrdNo);
m_grid1.QuickSetText(3, 0, ct.Format(_T("%Y/%m/%d %H:%M:%S")));
m_grid1.QuickSetText(4, 0, strStrategy);
m_grid1.QuickSetText(5, 0, strSymbol);
m_grid1.QuickSetText(6, 0, strOrdrActn);
m_grid1.QuickSetText(7, 0, strOrderType);
m_grid1.QuickSetText(8, 0, strCtgry);
m_grid1.QuickSetNumber(9, 0, nOrdrQty);
m_grid1.QuickSetNumber(10, 0, nOrdrPrice);
m_grid1.QuickSetNumber(11, 0, 0);
//****** Finally, goto to the top row and redraw to make the effect visible
m_grid1.GotoRow(0);
m_grid1.RedrawRow(0);
However everytime this code is executed, all logs are colored the same. What I want is to highlight the newly inserted row and reset the old highlighted row (that is, the second row) to the normal white/black background/text color.
I am not sure how I apply your answer to the above and could you modify the above code for me?
HR
|
|
|
|
|
hi
i'm using CUGExpandType to group some rows in my grid.
i need to get cell collapsed or expanded notification but in CUGExpandType.h file there is no definition for any event.
what should i do?
thx.
|
|
|
|
|
Hi
The celltypes normally notify the grid class (m_ctrl) through the OnCellTypeNotify fn. and in this case some code should be added:
void CUGExpandType::ExpandOrContract(int col, int row)
{
CUGCtrl * ctrl = this->m_ctrl;
CUGCell thisCell;
ctrl->GetCell(col, row, &thisCell);
CellData * cellData = GetCellData(col, row);
int numberOfRows = cellData->numberOfRows;
if(m_ctrl->OnCellTypeNotify(m_ID, col, row, cellData->isOpen, NULL) == FALSE) {
}
That should give a simple notification in your derived grid's OnCellTypeNotify callback, and from there you can add WM_NOTIFY code (see messages below) to pass along the event to a view or dialog of needed.
This is a bit of a quick reply - there could be specific defines for the celltype event added to ugdefine.h etc, but this might give you something to work with.
Tim
|
|
|
|
|
hi tim
thx for nice reply,
i couldn't have checked my inbox for a while cos i was trying to find some solution on my own way.
but it seems i was done a good job cos almost the same lines of code was added to get the UGExpand cell notification in my application.
i also found a way to set UGExpand cell initial expanding or collapsing state by injecting a funtion similar to CUGExpandType::SetNumberOfRows(int col, int row, int rows)
into UGCTExpand.cpp.
nice to see similiar ways indeed.
regards,
|
|
|
|
|
Hi Tim,
I have a suggestion for the next update. When a checkbox is disabled draw
the checkbox gray.
void CUGCheckBoxType::OnDraw(CDC *dc,RECT *rect,int col,long row,CUGCell *cell,int selected,int current)
{
....
CPen ltGrayPen;
ltGrayPen.CreatePen( PS_SOLID, 1, RGB(128,128,128));
if (isDisabled)
{
oldpen = (CPen*)dc->SelectObject(<GrayPen);
}
else
{
oldpen = (CPen*)dc->SelectStockObject(BLACK_PEN);
}
if (isDisabled)
{
dc->SelectObject(<GrayPen);
}
else
{
dc->SelectStockObject(BLACK_PEN);
}
-jc
|
|
|
|
|
Ok - thanks - filed in the updates box.
Tim
|
|
|
|
|
Hi Tim,
I'm having a problem with DeleteCell().
int nCols = m_nNumberOfColumns;
int sheetCount = GetNumberSheets();
int n = 0;
int nRetVal = 0;
for (int i=0; i < sheetCount; i++)
{
SetSheetNumber(i);
nSize = GetNumberRows();
for (int xRow = 0; xRow < nSize; xRow++)
{
for (int yCol=0; yCol < nCols; yCol++)
{
nRetVal = DeleteCell(yCol,xRow);
if (nRetVal == UG_ERROR)
{
AfxMessageBox(_T("Error"));
}
}
}
}
///////
The problem is the last tab, which is tab 5 (or sheet 4),
does not delete any of the cells. The first 4 tabs, all of the
cells get deleted. I checked the return value from DeleteCell(),
and the return value is UG_SUCCESS. Even though, none of cells
from tab 5 were deleted?
I tried changing the order of the sheets, and whichever sheet
that was made the last sheet, had the DeleteCell() problem.
I even tried cleaning up all of the project files, and then
rebooting the computer.
Any ideas?
Thanks,
-jc
|
|
|
|
|
Hmmm... well, you're clearing all the cells, right?
How bout looping from numrows-1 down to zero and calling DeleteRow? Or deleting row 0 numrows times?
Could be a Redraw problem - one test you could do is go to the last sheet, set number rows to 0 (which won't in itself kill the cell data in the datasource) then set the number rows back to where it was - see if the cell data persists.
Tim
|
|
|
|
|
I am using three different sets radiobuttons from ultimate grid, how do I show a groupbox with ultimate grid?
|
|
|
|
|
Hi
I don't think that functionality is built in - you might look at incorporating another cell on the left or top to act as a label, and could perhaps use CUG_Cell::SetBorder to outline things as a group.
Extending the celltype itself (UGCTRado.cpp) might be an option, adding a non-button string at the top of the cell - maybe this could be stored as the first item in the label text. Might not be too big a change to OnDraw , with some adjustment needed in OnLClicked .
Tim
|
|
|
|
|
hi
there is a resizing problem in mygrid.
my problem is when my dialog based application including mygrid is shown on the screen columns appear normal with with each have some witdh according to current dialog width/# of columns. When i put my mouse on the right edge of my dialog and drag towards left to decrease the dialog width my grid columns starts to get smaller and smaller towards left geometrically.. (more faster than my mouse dragging speed) just right most column keeps appearing but its left edge starts from where column 0 starts at the beginning. When i stop dragging left and starts dragging my mouse to right just last column covers whole grid area. really interesting..
so What should i do to keep my columns to have a proportinal width with my dialog or view client area? i don't want them to be fixed size but expands as proportinal to my grid container (width/# of columns).
i use COXLayoutManager to achieve to expand my grid with client area but how should i control individual columns?
by the way, i used
BestFit(-2, GetNumberCols()-1, GetNumberRows()-1, UG_BESTFIT_TOPHEADINGS); for my columns to expand when my dialog maximazed and it works ok. but resizing with mouse makes all columns messed up.
thx.
atilla.
|
|
|
|
|
ok. i solved my problem by handling WM_SIZE on my grid and setting my column widths according to my requirements. it's now behaving as expected.
by the way,
thx for ug
atilla.
|
|
|
|
|
Can Ultimate Grid be configured to fill the whole grid area with rows and columns, even though not all rows and columns are in use (e.g. like Excel)? I think it looks better to fill the whole grid area with rows and columns, instead of displaying a background color for unused rows and columns.
|
|
|
|
|
Maybe sort of kind of...
This isn't a built in feature, but you could play a bit, though there are limits - 32000 for cols, and long for rows.
Start with the datasource - the default datasource, CUGMemMan, iirc, doesn't allocate cells for the column info structs until data is set in a cell in that column. You could probably set a large number of cells then do some tracking to see which are actually used.
If using a custom datasource, this might be even more managable.
Mmmm... what type of data are you working with, and how flexible do you want this to be?
Tim
|
|
|
|
|
Hi Tim,
I'm sure, that you will be glad to
know, that we are just about finished
with our application.<g>
Anyway, we are using the printing
functions, and the printing works
OK. That is to say, it prints all
of the numeric and character columns.
However, it does not print any characters,
symbols, or anything in the checkbox
columns.
How do we get UTGrid to print an "X",
checkmark, or anything in the checkbox cell?
Currently, UTGrid displays an empty checkbox
cell.
Thanks,
-jc
|
|
|
|
|
Hi jc
I think I've the checkbox print ok - iirc you have themes turned on for the grid - does it print ok if the theming is turned off?
Tim
|
|
|
|
|
Hi Tim,
Actually, we have the UseThemes set to false.
However, once we switched the UseThemes to true,
and printed the report, the checkbox "marks" were
visible. The marks were barely visible. Are the marks
supposed to be asterisks "*"?
Currently, since we have no solution on how to make the checkbox
marks visible, when using UseThemes set to false, we are switching
to UseThemes set to true. We would like to use the "theme" that is
shown on the web page. The grid looks like style2, with the exception
that the row numbers and column header are both black, with style2.
How do we change the row numbers and column headers text to white?
And have the text background the same background as the header?
Also, are the checkbox marks barely visible, when printing, because
the screen checkbox marks are light green? How do we change the
checkbox marks to black, so that the marks are more visible when
printing?
Thanks,
-jc
modified on Wednesday, December 17, 2008 2:30 PM
|
|
|
|
|
Hmmm... there was a correction to the pen that the checkbox type was using in the Update 01 (here[^]). I'm assuming that update is applied, and that you don't have a disabled looking check on screen (not using themes).
Guess what's left is to step through the CUGCheckBoxType::OnDraw code when dc->IsPrinting . I don't have a tree eater at hand - can just check file and preview.
Tim
|
|
|
|
|
Hi Tim,
Thanks for the prompt reply.
Yes, we did apply the update patches, and we
did notice, in the code, the changes made by
Mr. Bret R..
We will continue to investigate the printing
issue. Also, in my last posting, I inquired
about the screen appearance. We are using theme
style2.
How do we change the row and column header background
text color to the blended "blue" color?
Also, regardless of the changes we make, the changes
do not appear to have any affect on the screen appearance.
Does using themes prevent the developer from further
customizing the look of the checkbox on the screen?
It's a bit confusing, we noticed, in the CUGExcel::OnSetup method,
that the colors that are set in the method, do not match the
colors on the screen??
Example:
GetCell(yCol, xRow, &cell);
style = cell.GetCellTypeEx();
style &= ~UG_BDR_RAISED;
style &= ~UG_BDR_RECESSED;
stlye |= UG_BDR_RTHIN|UG_BDR_BTHIN;
cell.SetCellTypeEx(style);
SetCell(yCol, xRow, &cell);
style &= ~UGCT_CHECKBOXDISABLED;
style |= UGCT_CHECKBOXDISABLED;
Also, if your comment, that you "do not have a tree eater" refers to a
printer. Then we have consumed several trees trying to get the printing
right.
Thanks,
-jc
modified on Wednesday, December 17, 2008 8:12 PM
|
|
|
|
|
Right - the code in the celltypes (which draw the cell) that respect theming call UGXPThemes::DrawEdge , UGXPThemes::WriteText , and UGXPThemes::DrawBackground instead of honoring the normal settings which is what is interfering here.
One work around for certain situations is to use code in OnGetCell to turn off theming for a particular cell with cell->UseThemes(FALSE) , but you'll lose things you might not have wanted to.
I don't quite get why, with style2, the side heading text is black - the excel demo shows white here (on XP with an XP theme - guess it would be different on Vista).
I did a quick test with the printing sample and do see the X (well, in Print preview, anyway). Also, I can understand that the themed check (check the celltypes demo for the various appearances) would look dithered - but the non-themed check should be drawn with a black pen, unless perhaps it's a tri-state check.
Odd - and sorry about the trees.
The grid theming is not an area I know very well. I think you buy in and hope it looks good on whatever OS/settings it's run on. Switching to Windows Classic makes it all go away, of course.
There's a UGXPThemes::SetXPTheme method that looks like it was intended to provide some fine grained control for some drawing aspects for the various celltypes states and components - have no experience with it but might be worth a look.
Are you using the CUGExcel / Mycug combination from the excel demo, with it's attendant side and top headings?
Tim
|
|
|
|
|
Hi Tim,
Thanks again, for your prompt reply.
Yes, we are using CUGExcel/Mycug combination from
the Excel demo.
You made an interesting comment, that the Excel
demo showed white text for the side headings.
Well, we tried an obvious test. We executed
our application on a 32-bit machine, running WinXP Pro.
Our application showed the white text as well, on a
32-bit machine.
Perhaps, WinXP Pro (x64) is the cause of many of
our problems.
We will most likely switch our development environment
to Win32. We will soon try the printing, on a 32-bit
machine.
Thanks,
-jc
|
|
|
|
|
Hi Tim,
I'm not quiet sure, if you suggested this or not,
but since I was unhappy with the printing of the skinned application
(i.e. "X" for a checkbox). After, I display the print dialog box
I set uxtheme to false, that allows me to have control over the
printing methods. Then, when the printing method is done I set the
theme back to true.
-jc
|
|
|
|
|
hi
first of all thx for UG. i'm playing with demos and tried to make a simple dialog based app for getting ins & outs.
my problem is that:
i have several columns one of them cell type is SpinButtonType. When i set my defaults for this col i getColDefault(colNumber, &cell).. and cell.SetNumber(15).. in OnSetUp(). UG appers properly but when i click spin button Up guess what happens?
cell value increments not to 16 but 1 as if i hadn't set cell number to 15 beforehand, it defaults itself to 0. ( i'm incrementing cell value in OnCellTypeNotify for spin button type cell..)
i think setting col defaults just draws text or number for column's cells. Becouse when i use QuickSetText(colNumber, rowNumber, 15); in OnSetUp for this cell i achieved to increment or decrement.
What i want to know is how can i set my cell default number for my column for once? i don't want to loop for each row in OnGetCell and OnGetCell is the last stop before drawing cell context i don't want to embed static number values in that function...
There should be a way what QuickSetText does for individual cells that does for column defaults as well which sets each newly added cell text as default.
thx.
atilla.
|
|
|
|
|
This is normal, but requires a bit of explanation.
When the grid draws a cell, it calls GetCellIndirect() , which gets the information from the column default for the cell (if any) before calling GetCell() on the datasource.
Since, at the start, only the default cell for the column has the 15, calling GetCell() in your OnCelltypeNotify() is not enough to get things going - you only get the cell data, not the defaults. If you were to call GetCellIndirect() , it should work as expected - but except for the first call, it will be superfluous - once the spin has been hit once, the correct value should be in the cell from your call to SetNumber() (or text) in the notification.
In this way column defaults are not the best choice for some properties - but if you are ok with the extra overhead of GetCellIndirect() it should still work.
Tim
|
|
|
|
|