合并单元格

风子啊啊 2019-03-17 04:17:28
cxgrid能不能横向合并单元格,各位帮忙一下!  如把A1.B1两个单元格合并
...全文
296 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
lyhoo163 2019-03-22
  • 打赏
  • 举报
回复
严格意义上,它并没有合并,而是将同值单元,显示出一个 单元。
sczyq 2019-03-20
  • 打赏
  • 举报
回复
void __fastcall TSheetOutput::MultiTitleMerge(TdxSpreadSheetTableView * AView, TRect ARect) { do { if (ARect.Top < ARect.Bottom) { String S = AView->CreateCell(ARect.Top, ARect.Left)->AsString; if (AView->CreateCell(ARect.Top + 1, ARect.Left)->IsEmpty) { // 如果下一行是空, 则将该列合并到底行 AView->MergedCells->Add(TRect(ARect.Left, ARect.Top, ARect.Left, ARect.Bottom)); } else if (ARect.Left < ARect.Right) // 如果是多列 { int LCount = 0; // 合并列数 while (ARect.Left + LCount < ARect.Right) if (SameText(S, AView->CreateCell(ARect.Top, ARect.Left + LCount + 1)->AsString)) LCount++; else break; if (LCount) { AView->ClearCells(TRect(ARect.Left + 1, ARect.Top, ARect.Left + LCount, ARect.Top), false, false); AView->MergedCells->Add(TRect(ARect.Left, ARect.Top, ARect.Left + LCount, ARect.Top)); if (ARect.Top < ARect.Bottom) MultiTitleMerge(AView, TRect(ARect.Left, ARect.Top+1, ARect.Left + LCount, ARect.Bottom)); ARect.Left += LCount; } else MultiTitleMerge(AView, TRect(ARect.Left, ARect.Top + 1, ARect.Left, ARect.Bottom)); } else MultiTitleMerge(AView, TRect(ARect.Left, ARect.Top + 1, ARect.Left, ARect.Bottom)); } ARect.Left++; } while (ARect.Left <= ARect.Right); } 这个是 BCB 的, 有纵向和横向的
风子啊啊 2019-03-18
  • 打赏
  • 举报
回复
引用 1 楼 lyhoo163的回复:
1)cxGridDBTableViewColumn1.Options.CellMerging:=true 2)编写代码 procedure TfrmYFCOPR01A.cxGrid1DBBandedTableView1PAB01CompareRowValuesForCellMerging( Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean); begin inherited; if (ARow1.Values[0] = ARow2.Values[0]) AND (ARow1.Values[1] = ARow2.Values[1]) then AAreEqual := True else AAreEqual := False; end;
这个是纵向,是上下两格的
lyhoo163 2019-03-17
  • 打赏
  • 举报
回复
1)cxGridDBTableViewColumn1.Options.CellMerging:=true 2)编写代码 procedure TfrmYFCOPR01A.cxGrid1DBBandedTableView1PAB01CompareRowValuesForCellMerging( Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean); begin inherited; if (ARow1.Values[0] = ARow2.Values[0]) AND (ARow1.Values[1] = ARow2.Values[1]) then AAreEqual := True else AAreEqual := False; end;

5,392

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧