 |
|
|
 |
|
|
Hi i am unable to download the attachment file.
Nice talking to you. If you judge people, you have no time to love them. -- Mother Teresa
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
when merging cells in virtual mode, it doesn't display properly. if any one would help me to fix it, i will be appreciated very much
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
I have a BIG problem since using the merged control. The CGridCellBase::PrintCell is a bit stuffed up for two fundamental reasons and I don't have the answer.
Firstly, there is a call at the start to pDC->Rectangle(rect) and this basically means avery cell gets all of the lines drawn! It is not obeying the users choices. The OnPrint function handles drawing the lines.
Also, it has some code remmed out and indicates it as disabled and this means my font colours are not showing.
How can I fix these two problems?
Thank you.
Andrew
|
| Sign In·View Thread·PermaLink | 1.50/5 (2 votes) |
|
|
|
 |
|
|
OK, I had a look at an older set of data files I have for the grid control and I noticed the PrintCell worked a little differently:
else crFG = (GetBackClr() != CLR_DEFAULT || (GetTextClr() != CLR_DEFAULT && GetTextClr() != pDefaultCell->GetTextClr())) ? GetTextClr() : RGB(0, 0, 0); This fixes my font colours. Now my print preview behaves for font colours.
As for the grid lines being drawn, I did this:
//Used for merge cells //by Huang Wei rect.InflateRect(1,1); // AJT // pDC->Rectangle(rect); rect.DeflateRect(1,1); This sorts me out. If I was using merged cells then I think I would have a problem here, but I don't. The thing is, it is the GRID that draws the cells grid lines in OnPrint just after the PrintCell call. Thus the ->Rectangle call should NOT be done in PrintCell. If anything, OnPrint should be adjusted just after the PrintCell call to allow for merged cells and thus print the boundary of the merged cell based on the GridLines parameters. I am not brave enough to do this. 
Andy
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
Thx for your great work~
I want to save the infomation of merged grid in database,for showing the grid in next time,thank U!
leon
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
Thx for your great work~
I want to add a bitmap file on a merged cell... or just on a cell.... Is there any way to do that????
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
I have it working by copying in the 4 files (which are v2.24) into the 2.26 code. however, there are problems (such as grid lines not showing up on colored backgrounds). There were several things changed from 224 to 226, but I do not have the older sources, so I can not tell what was changed.
If someone has the original 2.24 source files (prior to the Mergecell changes), That would also work, as a set of diff files can be created, to obtain JUST the modifications needed by the Mergecell functions.
TIA, Jim.
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
I complete this. compare file with the UltraEdit's then modify the file of 2.26 version
It compile successful and run successful
If you want to get the code, Then Mail Me,please; My Mail is geoh#vip.qq.com (replace # to @) the mail's subject must be MFC Grid Control with Merge! Thanks,My English is bad,Sorry
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
when merge cells in which some are already merged, the result is wrong. To fix this bug,you have to adjust the merged range to the actual range.
here is my solution:
void CGridCtrl::MergeCells(int nStartRow, int nStartCol, int nEndRow, int nEndCol) { // fixed the actual range, when some cells have already merged. // by hamo2008@gmail.com int nMinRow= nStartRow,nMaxRow= nEndRow,nMinCol= nStartCol,nMaxCol= nEndCol; for (int row1=nStartRow;row1<=nEndRow;row1++) { for (int col1=nStartCol;col1<=nEndCol;col1++) { CGridCellBase *pCell= (CGridCellBase*)GetCell(row1,col1); ASSERT(pCell); if (pCell->IsMerged()) { CCellRange range=pCell->GetMergeRange(); nMinRow = min(nMinRow,range.GetMinRow()); nMinCol = min(nMinCol,range.GetMinCol()); nMaxRow = max(nMaxRow,range.GetMaxRow()); nMaxCol = max(nMaxCol,range.GetMaxCol()); } } }
nStartRow = nMinRow; nEndRow = nMaxRow; nStartCol = nMinCol; nEndCol = nMaxCol;
// below is the original code for(int row=nStartRow;row<=nEndRow;row++) //.... }
---- You have nothing to lost, but everything to gain. http://www.ucosoft.com
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|

I can delete rows grom the grid , even when there are merged rows.
but, if my very last row is merged, it crashes.
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
Surely this code is wrong?
void CGridCellBase::operator=( CGridCellBase& cell) { if (this == &cell) return;
SetGrid(cell.GetGrid()); // do first in case of dependencies
SetText(cell.GetText()); SetImage(cell.GetImage()); SetData(cell.GetData()); SetState(cell.GetState()); SetFormat(cell.GetFormat()); SetTextClr(cell.GetTextClr()); SetBackClr(cell.GetBackClr()); SetFont(cell.IsDefaultFont()? NULL : cell.GetFont()); SetMargin(cell.GetMargin()); //Used for merge cells //by Huang Wei SetMergeCellID(cell.GetMergeCellID()); SetMergeRange(cell.GetMergeRange()); Show(cell.IsShow()); }
When you look at SetMergeRange:
//Used for merge cells //by Huang Wei void CGridCellBase::SetMergeRange(CCellRange range) { m_MergeRange=range; m_bBaseForMerged = 1; }
It always sets the cell as a merged base cell. But what if it not actually a merged cell in the first place that you are copying or doing stuff with? I wonder if this is the cause of my crashes.
I would have thought that it should be passing in the state of the cell.XXXXX merging properties.
Can some one help me here?
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
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).
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
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; } }
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
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
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
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.
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
 |
|
|
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
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
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!
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
When I use the virtual mode and merge some cells, it seems that the callback-funktion never called again!?
|
| Sign In·View Thread·PermaLink | 1.14/5 (4 votes) |
|
|
|
 |
|
|
 |