|
Hi Atilla
Yes, there is a problem here. It may be a issue with the overall height of the group not updating properly when an individual row is resized.
Will have a look.
Tim
|
|
|
|
|
Hi Atilla
Took me a while to see this - looks like the code wasn't storing the 0 row height.
In the CUGExpandType::ExpandOrContract method change the code at line 156 to check for >= 0 , not > 0 .
if (!isOpen)
{
int height = ctrl->GetRowHeight(row);;
if (height >= 0)
{
m_mapColumnHeights[row] = height;
height = 0;
ctrl->OnRowSizing(row,&height);
ctrl->SetRowHeight(row,height);
}
}
else Tim
|
|
|
|
|
hi tim,
good catch
thx.
atilla.
|
|
|
|
|
hi,
i want to implement a row ordering functionality with my UG. When i click on spin button up and down arrows i want my current row to move up and down as well. ( i do not use drag & drop )
is there an easy way to move (cut/delete) any selected row from and paste/insert it into another selected position?
is there have a built in functionality in CUGCtrl to make row ordering an ease?
Or should i go with copying all column info for current row and use ::DeleteRow(long row) and then use ::InsertRow(long row) a new row by pasting/setting all column info into that new row?
thx.
|
|
|
|
|
hi
i've done what i needed.
here is the code block. this is the editbox OnChange handler for the spin button control. every field in my Grid is located inside a UGCTExpand group cell and each field has its order index. Lets say group has 5 fields and Field_Name has index 4. There are several groups where each group have several fields. When i press spin up-down i move current row up and down and update my field index value and current row for the next time...
void CGridPropertyDlg::OnChangeFieldOrder()
{
CUGCell cell;
if(m_bIsSpinPosSet)
{
FieldCell* curCell = (FieldCell*) GetCurrentAtiCell(m_curCol, m_curRow);
int fldIndex = curCell->m_FieldIndex;
int curPos = m_SpinFieldOrder.GetPos();
int upRange, loRange;
m_SpinFieldOrder.GetRange(loRange, upRange);
if(curPos>fldIndex)
{
FieldCell* nextCell = (FieldCell*) GetCurrentAtiCell(m_curCol, m_curRow+1);
m_pGrid->InsertRow(m_curRow+2);
for(int i=-1; i<m_pGrid->GetNumberCols(); i++)
{
m_pGrid->GetCell(i, m_curRow, &cell);
m_pGrid->SetCell(i, m_curRow+2, &cell);
}
m_pGrid->DeleteRow(m_curRow);
m_pGrid->GotoCell(0, m_curRow+1);
curCell->m_FieldIndex = curPos;
curCell->SetLocation(m_curCol, m_curRow+1);
nextCell->m_FieldIndex = curPos+1;
nextCell->SetLocation(m_curCol, m_curRow);
m_curRow++;
m_pGrid->RedrawAll();
}
else if(curPos<fldIndex)
{
FieldCell* prevCell = (FieldCell*) GetCurrentAtiCell(m_curCol, m_curRow-1);
m_pGrid->InsertRow(m_curRow-1);
for(int i=-1; i<m_pGrid->GetNumberCols(); i++)
{
m_pGrid->GetCell(i, m_curRow+1, &cell);
m_pGrid->SetCell(i, m_curRow-1, &cell);
}
m_pGrid->DeleteRow(m_curRow+1);
m_pGrid->GotoCell(0, m_curRow-1);
curCell->m_FieldIndex = curPos;
curCell->SetLocation(m_curCol, m_curRow-1);
prevCell->m_FieldIndex = curPos+1;
prevCell->SetLocation(m_curCol, m_curRow);
m_curRow--;
m_pGrid->RedrawAll();
}
}
}
hope useful for someone else,,,
atilla.
|
|
|
|
|
The Code has the correct background before the attach statement, but draws a semi random color (color stays the same for a while and then changes).
The BackGround color in cells works correctly.
I am using the latest grid code, with VST 2005,win2008 SDK library update on XP SP3.
Using the default MYCug skeleton attached to a CSTATIC in a CFormView.
Link is to MFC in Static library, not UNicode.
|
|
|
|
|
I Found the problem I linked the ole version of the library into a non ole app.
This produces NO ERRORS from the linker but messes up the VTABLE and the wrong function are getting called at several points in the code.
Example OnAdjustComponent Sizes was getting called in my code.
setFocusRect was getting called when stepping through code with the debugger.
It Would be a really good Ideas to have each version of the library define
a unique symbol and an include file that would request in your app so you can make sure you are linking to the correct code.
modified on Saturday, January 3, 2009 4:14 AM
|
|
|
|
|
mhorowit wrote: It Would be a really good Ideas to have each version of the library define
a unique symbol and an include file that would request in your app so you can make sure you are linking to the correct code.
Food for thought - I've seen this affect builds in less subtle ways.
Filed in the updates bucket - thanks.
Tim
|
|
|
|
|
m_grid1.AttachGrid(this, IDC_GRID);
m_grid1.SetUniformRowHeight(TRUE);
m_grid1.SetNumberRows(0, FALSE);
m_grid1.SetNumberCols(13, FALSE);
//******* Set Highlight Mode
m_grid1.SetHighlightRow(TRUE);
m_grid1.QuickSetText(-1, -1, _T("RecNo"));
m_grid1.QuickSetText(0, -1, _T("MC/TS"));
m_grid1.QuickSetText(1, -1, _T("AUTOBS##"));
m_grid1.QuickSetText(2, -1, _T("OrdNo"));
m_grid1.QuickSetText(3, -1, _T("Time"));
m_grid1.QuickSetText(4, -1, _T("Strategy"));
m_grid1.QuickSetText(5, -1, _T("Symbol"));
m_grid1.QuickSetText(6, -1, _T("Action"));
m_grid1.QuickSetText(7, -1, _T("Type"));
m_grid1.QuickSetText(8, -1, _T("Category"));
m_grid1.QuickSetText(9, -1, _T("Qty"));
m_grid1.QuickSetText(10, -1, _T("Price"));
m_grid1.QuickSetText(11, -1, _T("EntryID"));
m_grid1.QuickSetText(12, -1, _T("Message"));
//****** Declare a CUGCell Object
CUGCell cell;
//****** Set the heading default
m_grid1.GetHeadingDefault(&cell);
cell.SetBackColor(RGB(0,255,0));
m_grid1.SetHeadingDefault(&cell);
//****** Add a new row
int ans = m_grid1.InsertRow(0);
cell.SetBackColor(RGB(0, 255, 255));
cell.SetTextColor(RGB(0, 0, 0));
m_grid1.QuickSetRange(0, 0, mr_grid1.GetNumberCols() - 1, 0, &cell);
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);
m_grid1.GotoRow(0);
m_grid1.RedrawRow(0);
//****** Add next row
int ans = m_grid1.InsertRow(0);
cell.SetBackColor(RGB(0, 255, 255));
cell.SetTextColor(RGB(0, 0, 0));
m_grid1.QuickSetRange(0, 0, m_grid1.GetNumberCols() - 1, 0, &cell);
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);
m_grid1.GotoRow(0);
m_grid1.RedrawRow(0);
The above code inserts two rows and colors them. However I want to reset the background color of the second row (originally first row) to white when I insert a new row (new first row).
How can I do that please?
|
|
|
|
|
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
|
|
|
|
|