コード例 #1
0
        private void gridView1_RowCellStyle(object sender, RowCellStyleEventArgs e)
        {
            GridCellInfoCollection cells = GetMergeCells(gridView1.FocusedRowHandle, gridView1.FocusedColumn);

            if (cells != null)
            {
                foreach (GridCellInfo cell in cells)
                {
                    if (cell.RowHandle == e.RowHandle && e.Column.VisibleIndex > gridView1.FocusedColumn.VisibleIndex)
                    {
                        e.Appearance.BackColor = Color.Orange;
                    }
                }
            }
        }
コード例 #2
0
        private void RefreshRow(int rowHandle, GridColumn column)
        {
            if (!gridView1.IsValidRowHandle(rowHandle) || column == null)
            {
                return;
            }
            List <GridColumn>      columns = gridView1.VisibleColumns.OfType <GridColumn>().Where(x => x.VisibleIndex > column.VisibleIndex).ToList();
            GridCellInfoCollection cells   = GetMergeCells(rowHandle, column);

            if (cells != null)
            {
                foreach (GridCellInfo cell in cells)
                {
                    foreach (GridColumn col in columns)
                    {
                        gridView1.RefreshRowCell(cell.RowHandle, col);
                    }
                }
            }
        }
        private Rectangle GetSelectionBounds()
        {
            int          width        = 0;
            int          height       = 0;
            Rectangle    rTop         = Rectangle.Empty;
            bool         shouldReturn = false;
            GridView     view         = GridControl.FocusedView as GridView;
            GridViewInfo info         = view.GetViewInfo() as GridViewInfo;

            GridCell[] gridCells = view.GetSelectedCells();
            if (gridCells.Length == 0)
            {
                shouldReturn = true;
                return(Rectangle.Empty);
            }
            Brush hb = Brushes.Black;
            List <GridCellInfo> visibleColl = new List <GridCellInfo>();

            foreach (GridRowInfo row in info.RowsInfo)
            {
                if (row is GridGroupRowInfo)
                {
                    continue;
                }
                GridCellInfoCollection coll = (row as GridDataRowInfo).Cells;
                foreach (GridCellInfo cell in coll)
                {
                    visibleColl.Add(cell);
                }
            }
            List <GridCellInfo> collection = new List <GridCellInfo>();

            foreach (GridCell cell in gridCells)
            {
                foreach (GridCellInfo cellInfo in visibleColl)
                {
                    if (cellInfo.RowInfo != null && cellInfo.ColumnInfo != null)
                    {
                        if (cell.RowHandle == cellInfo.RowHandle && cell.Column == cellInfo.Column)
                        {
                            collection.Add(cellInfo);
                        }
                    }
                }
            }
            if (collection.Count == 0)
            {
                shouldReturn = true;
                return(Rectangle.Empty);
            }
            rTop = GetCellRect(view, collection[0].RowHandle, collection[0].Column);
            Rectangle rBottom = GetCellRect(view, collection[collection.Count - 1].RowHandle, collection[collection.Count - 1].Column);

            if (rTop.Y > rBottom.Y)
            {
                height = rTop.Y - rBottom.Bottom;
            }
            else
            {
                height = rBottom.Bottom - rTop.Y;
            }

            if (rTop.X <= rBottom.X)
            {
                width = rBottom.Right - rTop.X;
            }
            else
            {
                width = rTop.X - rBottom.Right;
            }
            return(new Rectangle(rTop.X, rTop.Y, width, height));
        }