Пример #1
0
        void view_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            Rectangle textRect = e.Bounds;

            MyMergedCellInfo currentInfo = null;

            foreach (MyMergedCellInfo item in mergedCells)
            {
                if (item.RowHandle == View.GetDataSourceRowIndex(e.RowHandle) && item.Columns.Contains(e.Column))
                {
                    currentInfo = item;
                    break;
                }
            }
            if (currentInfo != null)
            {
                int        clipBoundsX = 0;
                RectangleF currentClip = e.Graphics.ClipBounds;
                if (currentInfo != null)
                {
                    foreach (GridColumn item in currentInfo.Columns)
                    {
                        if (item == e.Column)
                        {
                            continue;
                        }
                        if (currentInfo.Columns.IndexOf(item) > currentInfo.Columns.IndexOf(e.Column))
                        {
                            textRect.Width += item.VisibleWidth;
                        }
                        else
                        {
                            textRect.X     -= item.VisibleWidth;
                            textRect.Width += item.VisibleWidth;
                        }
                    }
                    e.DisplayText = currentInfo.DisplayText;
                    clipBoundsX   = (int)currentClip.X < e.Bounds.X ? e.Bounds.X - 4 : (int)currentClip.X;

                    if (View.LeftCoord > 0)
                    {
                        e.Cache.ClipInfo.SetClip(new Rectangle(clipBoundsX, (int)currentClip.Y, textRect.Width, (int)currentClip.Height));
                    }

                    IndentInfoCollection lines        = (e.Cell as GridCellInfo).RowInfo.Lines;
                    List <IndentInfo>    removedLines = new List <IndentInfo>();
                    foreach (IndentInfo currentLine in lines)
                    {
                        if (textRect.X <= (currentLine.Bounds.X - View.LeftCoord) && (textRect.Width + textRect.X) >= (currentLine.Bounds.X - View.LeftCoord) && currentLine.Bounds.Y <= textRect.Y && (currentLine.Bounds.Y + currentLine.Bounds.Height) >= textRect.Y)
                        {
                            currentLine.OffsetContent(-currentLine.Bounds.X, -currentLine.Bounds.Y);
                        }
                    }
                }
                e.Appearance.DrawBackground(e.Cache, textRect);
                e.Appearance.DrawString(e.Cache, e.DisplayText, textRect);
                e.Handled = true;
                e.Cache.ClipInfo.SetClip(new Rectangle((int)currentClip.X, (int)currentClip.Y, (int)currentClip.Width, (int)currentClip.Height));
            }
        }
Пример #2
0
        public void MergeCells(string sValue, int iRowHandle, GridColumn[] gridColumns)
        {
            MyMergedCellInfo myCellInfo = new MyMergedCellInfo(sValue, iRowHandle);

            foreach (GridColumn item in gridColumns)
            {
                myCellInfo.Columns.Add(item);
            }
            mergedCells.Add(myCellInfo);
        }