Beispiel #1
0
 protected internal void RaiseMergeRowCells(AllowMergeRowCellsEventArgs args)
 {
     if (AllowMergeRowCells != null)
     {
         AllowMergeRowCells(this, args);
     }
 }
        protected override void CalcRowCellsInfo(RowInfo ri)
        {
            base.CalcRowCellsInfo(ri);
            if (!((MyTreeList)TreeList).OptionsView.AllowHorizontalMerge)
            {
                return;
            }

            if (TreeList.OptionsSelection.EnableAppearanceFocusedRow)
            {
                TreeList.OptionsSelection.EnableAppearanceFocusedRow = false;
            }

            for (int i = ri.Cells.Count - 1; i > 0; i--)
            {
                string prevDisplayText = GetCellDisplayText(ri, i - 1);
                string currDisplayText = GetCellDisplayText(ri, i);

                AllowMergeRowCellsEventArgs args = new AllowMergeRowCellsEventArgs(ri, i, i - 1);
                ((MyTreeList)TreeList).RaiseMergeRowCells(args);
                if (args.Merge == DevExpress.Utils.DefaultBoolean.False)
                {
                    continue;
                }

                if ((prevDisplayText == currDisplayText) || (args.Merge == DevExpress.Utils.DefaultBoolean.True))
                {
                    CellInfo prevCell = ri.Cells[i - 1];
                    CellInfo currCell = ri.Cells[i];

                    for (int j = ri.Lines.Count - 1; j >= 0; j--)
                    {
                        LineInfo lineInfo = ri.Lines[j];
                        if (lineInfo.Appearance != PaintAppearance.VertLine)
                        {
                            continue;
                        }

                        if (lineInfo.Bounds.X == prevCell.Bounds.X + prevCell.Bounds.Width)
                        {
                            ri.Lines.RemoveAt(j);
                            break;
                        }
                    }

                    Rectangle mergedBounds = new Rectangle(prevCell.Bounds.X, prevCell.Bounds.Y, currCell.Bounds.Right - prevCell.Bounds.X, prevCell.Bounds.Height);
                    prevCell.SetBounds(mergedBounds, new System.Windows.Forms.Padding(0));
                    mergedBounds.Inflate(-1, -1);
                    prevCell.CalcViewInfo(GInfo.Cache, Point.Empty);
                    prevCell.EditorViewInfo.Bounds = mergedBounds;

                    ri.Cells.RemoveRange(i - 1, 2);
                    ri.Cells.Insert(i - 1, prevCell);
                    base.UpdateCellInfo(prevCell, prevCell.RowInfo.Node);
                }
            }
        }
 private void treeList1_AllowMergeRowCells(object sender, AllowMergeRowCellsEventArgs e)
 {
     if (e.Node.HasChildren == true)
     {
         e.Merge = DevExpress.Utils.DefaultBoolean.True;
     }
     else
     {
         e.Merge = DevExpress.Utils.DefaultBoolean.Default;
     }
 }