Home > Back-end >  Merge cells
Merge cells

Time:11-15

Can cxgrid horizontal merger, cell everybody to help! Such as the A1, B1 merge two cells

CodePudding user response:

1) cxGridDBTableViewColumn1. Options. CellMerging:=true
2) write the code
Procedure TfrmYFCOPR01A. CxGrid1DBBandedTableView1PAB01CompareRowValuesForCellMerging (
Sender: TcxGridColumn; ARow1: TcxGridDataRow;
AProperties1: TcxCustomEditProperties; Const AValue1: Variant;
ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties;
Const AValue2: Variant; Var AAreEqual: Boolean);
The begin
Inherited;
If (ARow1. Values. [0]=ARow2 Values [0]) AND (ARow1. Values. [1]=ARow2 Values [1]), then the
AAreEqual:=True
The else
AAreEqual:=False;
end;

CodePudding user response:

reference 1st floor lyhoo163 response:
1) cxGridDBTableViewColumn1. Options. CellMerging:=true
2) write the code
Procedure TfrmYFCOPR01A. CxGrid1DBBandedTableView1PAB01CompareRowValuesForCellMerging (
Sender: TcxGridColumn; ARow1: TcxGridDataRow;
AProperties1: TcxCustomEditProperties; Const AValue1: Variant;
ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties;
Const AValue2: Variant; Var AAreEqual: Boolean);
The begin
Inherited;
If (ARow1. Values. [0]=ARow2 Values [0]) AND (ARow1. Values. [1]=ARow2 Values [1]), then the
AAreEqual:=True
The else
AAreEqual:=False;
end;

This is a longitudinal, upper and lower case

CodePudding user response:

Void __fastcall TSheetOutput: : MultiTitleMerge (TdxSpreadSheetTableView * AView, TRect ARect)
{
Do
{
If (ARect. Top & lt; ARect. Bottom)
{
String S=AView - & gt; CreateCell (ARect. Top ARect. Left) - & gt; AsString;
If (AView - & gt; CreateCell (ARect. Top + 1, ARect. Left) - & gt; IsEmpty)
{//if the next row is empty, incorporating the column line exactly
AView - & gt; MergedCells - & gt; Add (TRect (ARect ARect. Left, Top, ARect. Left, ARect. Bottom));
}
Else if (ARect Left & lt; ARect. Right)//if it is multiple columns
{
Int LCount=0;//merge columns

While (ARect. Left + LCount & lt; ARect. Right)
If (SameText (S, AView - & gt; CreateCell (ARect. Top, ARect Left + LCount + 1) - & gt; AsString) are identical)
LCount++;
The else break;

If (LCount)
{
AView - & gt; ClearCells (TRect (ARect. Left + 1,
ARect. Top ARect. Left + LCount, ARect. Top), false, false);

AView - & gt; MergedCells - & gt; Add (TRect (ARect ARect. Left, Top,
ARect. Left + LCount, ARect. Top));

If (ARect. Top & lt; ARect. Bottom)
MultiTitleMerge (AView, TRect (ARect Left,
ARect. Top + 1, ARect Left + LCount, ARect. Bottom));
ARect. Left +=LCount;
}
The else MultiTitleMerge (AView, TRect (ARect. Left,
ARect. Top + 1, ARect Left, ARect. Bottom));
}
The else MultiTitleMerge (AView, TRect (ARect. Left,
ARect. Top + 1, ARect Left, ARect. Bottom));
}
ARect. Left++;
} while (ARect Left & lt;=ARect. Right);
}


This is the BCB, there are vertical and horizontal

CodePudding user response:

Strict sense, it does not merge, but will work with unit value, showing a unit,
  • Related