cxgrid能不能橫向合并單元格,各位幫忙一下! 如把A1.B1兩個單元格合并
uj5u.com熱心網友回復:
1)cxGridDBTableViewColumn1.Options.CellMerging:=true2)撰寫代碼
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;
uj5u.com熱心網友回復:
這個是縱向,是上下兩格的
uj5u.com熱心網友回復:
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 的, 有縱向和橫向的
uj5u.com熱心網友回復:
嚴格意義上,它并沒有合并,而是將同值單元,顯示出一個 單元。轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/32628.html
標籤:VCL組件開發及應用
