 |
|
 |
The bug sniffer has been at work. Do this to avoid the problems:
Step 1:
In CGridCellBase operator= change:
SetMergeRange(cell.GetMergeRange());
to
SetMergeRange(cell.GetMergeRange());
m_bBaseForMerged = cell.IsBaseForMerged();
The bug in SetMergeRange is here:
void CGridCellBase::SetMergeRange(CCellRange range)
{
m_MergeRange=range;
--> m_bBaseForMerged = 1; <---
}
It should not do that. It should be using the value of the cell being copied. Only true merged cells should have a base flag set.
Step 2:
In CGridCellBase InflateMergedRange change to:
void CGridCellBase::InflateMergedRange(int cx, int cy)
{
if (IsMerged())
{
m_MergeRange.Set(
m_MergeRange.GetMinRow() + cy,
m_MergeRange.GetMinCol() + cx,
m_MergeRange.GetMaxRow() + cy,
m_MergeRange.GetMaxCol() + cx
);
}
else if(IsMergeWithOthers())
{
m_MergeCellID.row += cy;
m_MergeCellID.col += cx;
}
}
The bug is that only the BASE base has a valid range object.
Likewise, only merged cells utilise a merged cell id object.
The merged cell id object was not getting updated, so the merged cells now pointed to the wrong master base cell.
Because we have now corrected the operator= call in step 1, we could use IsBaseForMerge instead of IsMerged. But this works using the existing method IsMerged.
Step 3:
In CGridCtrl::InflateMergedRanges change to:
void CGridCtrl::InflateMergedRanges(int nStartRow, int nStartCol, int cx, int cy)
{
for(int i = nStartRow; i < GetRowCount(); i++)
{
for(int j = nStartCol; j < GetColumnCount(); j++)
{
if(GetCell(i, j)->IsMerged() || GetCell(i, j)->IsMergeWithOthers())
{
GetCell(i, j)->InflateMergedRange(cx, cy);
}
}
}
}
As described for step 2, you need to intercept and modify both base cell (with a merge range) and merged cells (with a merged cell id).
|
|
|
|
 |
|
 |
When you autosize a column, and the cell is merged and the master cell, the column ends up being resized and the grid can effectively double in width.
I did this to overcome the problem:
AutoSizeColumn:
for (int nRow = nStartRow; nRow <= nEndRow; nRow++)
{
CGridCellBase* pCell = GetCell(nRow, nCol);
// AJT Avoid merged cells in calculations
if (pCell && !pCell->IsMerged())
{
size = pCell->GetCellExtent(pDC);
if (size.cx > nWidth)
nWidth = size.cx;
}
}
|
|
|
|
 |
|
 |
I have some problems here. Can anyone help me solve them?
1. In order to set a merged set of cells as the focus cell, you must click on the "base" cell for the merged cells. You can't click on any of them.
2. Related to this (perhaps). My grid uses combo cells and the odd row of merged text cells. If I am on a combo cell and the move down a row using the cursor key, it renders the dropdown arrow of the hidden combo cell. This would explain why item 1 above does not let you click a none-based merged cell.
The question is how can I solve these two problems? It would be nice to click on any merged cell and it set the focus correctly and it would be nice when moving up/down etc. that it set the focus cell correctly.
Andrew
|
|
|
|
 |
|
 |
What you have to do is not let the grid set focus to a cell that is merged with others. Add this code to SetFocusCell:
// EFW - Bug Fix - Force focus to be in a non-fixed cell
if (cell.row != -1 && cell.row < GetFixedRowCount())
cell.row = GetFixedRowCount();
if (cell.col != -1 && cell.col < GetFixedColumnCount())
cell.col = GetFixedColumnCount();
*** NEW CODE ***
// AJT Bug Fix
CGridCellBase *pCell = NULL;
pCell = GetCell(cell);
if(pCell != NULL && pCell->IsMergeWithOthers())
cell = pCell->GetMergeCellID();
Now, it will select the right cell and this works for mouse and cursor movements. It also avoids the rendering of grid lines.
|
|
|
|
 |
|
 |
Do you have the CGridCtrl with MergeCell function ?
|
|
|
|
 |
|
 |
Can't the same instructions be followed in 2.25?
Andrew
|
|
|
|
 |
|
 |
Hi,
If i have text in cell (1,1) and i merged cells (1,1,1,7)
and when my text is too big for cell (1,1) AutoSize function resizes my (1,1) cells, but my text isn't too big for merged cells (1,1,1,7) (i mean there is a lot of place in whole row which is merged as one cells)$;
Better for me would be AutoSize also for merge cells.
Hmm, i will try to draw mky problem;
I have :
|______|_____|
|MyBigText___| <-this one is merged
After using AutoSize i have
|_________|_____|
|MyBigText______|
Column number 0 shouldn't be resized
// ___ means spacebar
Somebody helps me?
Thanks a lot.
//I hope i will be understood
df
|
|
|
|
 |
|
 |
Using the grid control to print, you may see that the last line of the grid can't be show. After several hours of debuging, I found it will be OK only if you chang "white_rect.top=range.bottom + 1;" to "white_rect.top=range.bottom + 2;" in function--void CGridCtrl::OnPrint(CDC *pDC, CPrintInfo *pInfo), good lucky!
|
|
|
|
 |
|
 |
Hi,
can anyone send me the zip file.
I cannot download it.
Thanks & Regards
Manju
|
|
|
|
 |
|
 |
When I use the virtual mode and merge some cells, it seems that the callback-funktion never called again!?
|
|
|
|
 |
|
 |
What about simple word wrapping support for the grid control?
|
|
|
|
 |
|
 |
m_pGridCtrl->SetItemFormat(2,0, DT_WORDBREAK);
|
|
|
|
 |
|
 |
I will have to try this. But my other concern is for when the grid is printed out. The widths of the columns need to be proportional to the printer so that what I see on screen is the same as the printer. I don't want it the other way round where the printer does what teh screen shows. This way I ensure it will fit on the printer one page wide.
Not sure how to accomplish that with a grid in a doc/view framework...
|
|
|
|
 |
|
 |
Please if anyone knows how to make tree cells and merged cells works on the same grid tell me how.
Thanks in advance,
Rafael Melo
|
|
|
|
 |
|
 |
Firstly,thank Huang Wei for this usefull Merge Cells GridControl!
Now I use several GridControls in a Document/View application, how can I print it? The gridCpntrol seems can only print one of them.
|
|
|
|
 |
|
 |
who can send me one?
thanks!
liuxing2001@hotmail.com
|
|
|
|
 |
|
 |
I aplly your modification to 2.25Version,It seem not work.
|
|
|
|
 |
|
 |
Well it works for me. I added fix by shawkins (no border lines during selection). If somebody wants the code send me an email.
Gezo
|
|
|
|
 |
|
 |
I am looking for a 2.25 with any bugs fixed that include merge cells support. Can you email this to me please?
|
|
|
|
 |
|
 |
I am looking for a 2.25 with any bugs fixed that include merge cells support. Can you email this to me please?
|
|
|
|
 |
|
 |
I am looking for a 2.25 with any bugs fixed that include merge cells support. Can you email this to me please?
homerhuang
|
|
|
|
 |
|
 |
I have modified it in 2.25 version as you doing in 2.24,and it works very well. Thank you very much for your working!
|
|
|
|
 |
|
 |
Use the Sample Application providd with the Grid View with Merge Cell Support.
Scroll to the right so that part of the merged cell is only viewable. Then minimize and maximise the girdview(Gridvi1). The merged cell is shown in the background . What may be the problem Help?
|
|
|
|
 |
|
 |
I had the same problem when I scrolled verticaly. The two bugs are identical so what I have done for my problem can be easily adapted for yours.
In the GridCtrl.cpp file, search for the OnDraw function. Then inside of this function, we have a part commented as :
// draw rest of non-fixed cells"
Inside this block of code, begining with
rect.bottom = nFixedRowHeight-1;
for (row = minVisibleRow; row <= maxVisibleRow; row++)
You will find the following line :
if(!pCell->IsMergeWithOthers())
Replace it by :
if(!pCell->IsMergeWithOthers() || row == minVisibleRow )
One of the next lines is :
pCell->Draw(pDC, row, col, rect, FALSE);
Replace it by :
if( row == minVisibleRow && pCell->IsMergeWithOthers())
pCell->KLDraw(pDC, row, col, rect, FALSE);
else
pCell->Draw(pDC, row, col, rect, FALSE);
Where KLDraw is exactly the same as the Draw function but without the lines :
if(m_Hide && !IsMerged())
{
return TRUE;
}
That works for me and solve my problem with the vertical scroll and the resize of the grid.
Minimum changes should be made to solve the same problem with the horizontal croll.
|
|
|
|
 |
|
 |
This is only informtation for those who have the same problem.
I solve it by small changing function
void CGridCtrl::PrintColumnHeadings(CDC *pDC, CPrintInfo* /*pInfo*/)
Main loop I change from:
for (int row = 0; row < GetFixedRowCount(); row++)
to:
for (int row = 0; row < GetRowCount(); row++)
Maybe it isn't "neat" and it is worth to fix it in next version.
Wojtek
|
|
|
|
 |