Ejemplo n.º 1
0
 void grid_LeftColChanged(object sender, GridRowColIndexChangedEventArgs e)
 {
     if (ShowLayoutLines)
     {
         grid.Invalidate();
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// After rows were scrolled.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnTopRowChanged(GridRowColIndexChangedEventArgs e)
        {
            base.OnTopRowChanged(e);
            //inTopRowChanging = false;

            if (centerTextInVisibleCellPart && e.Success)
            {
                int  rowIndex1 = TopRowIndex - 1;
                bool visRow1   = false;//ViewLayout.IsRowVisible(rowIndex1) && savedTopVisible;

                int  rowIndex2 = savedBottomRow;
                bool visRow2   = !ViewLayout.HasPartialVisibleRows;

                int clientCols = ViewLayout.VisibleCols;

                if (!visRow1 || !visRow2)
                {
                    GridRangeInfoList ranges = new GridRangeInfoList();

                    for (int n = 0; n < clientCols; n++)
                    {
                        int           colIndex = GetCol(n);
                        GridRangeInfo mergeRange;

                        if (!visRow1)
                        {
                            int r = Math.Max(rowIndex1, savedTopRow);
                            if (Model.MergeCells.Find(GridMergeCellDirection.RowsInColumn,
                                                      r, colIndex, out mergeRange) &&
                                !ranges.Contains(mergeRange))
                            {
                                if (mergeRange.Bottom >= TopRowIndex)
                                {
                                    // found a merged range that is only partially visible and this
                                    // needs to be fully repainted (since we do want to center text
                                    // within the visible boundaries of the cell only and not scroll
                                    // centered text out of view).
                                    Update();
                                    RefreshRange(mergeRange);
                                    ranges.Add(mergeRange);
                                }
                            }
                        }
                        if (!visRow2)
                        {
                            if (Model.MergeCells.Find(GridMergeCellDirection.RowsInColumn,
                                                      rowIndex2, colIndex, out mergeRange) &&
                                !ranges.Contains(mergeRange))
                            {
                                if (mergeRange.Top <= rowIndex2)
                                {
                                    // found a merged range that is only partially visible and this
                                    // needs to be fully repainted (since we do want to center text
                                    // within the visible boundaries of the cell only and not scroll
                                    // centered text out of view).
                                    Update();
                                    RefreshRange(mergeRange);
                                }
                            }
                        }
                    }
                }
            }
        }