private void UpdateGridSize()
        {
            GridViewInfo viewInfo   = (GridViewInfo)gridView1.GetViewInfo();
            FieldInfo    fi         = typeof(GridView).GetField("scrollInfo", BindingFlags.Instance | BindingFlags.NonPublic);
            ScrollInfo   scrollInfo = (ScrollInfo)fi.GetValue(gridView1);
            int          width      = viewInfo.ViewRects.IndicatorWidth;

            foreach (GridColumn column in gridView1.VisibleColumns)
            {
                if (viewInfo.GetColumnLeftCoord(column) < viewInfo.ViewRects.ColumnPanelWidth)
                {
                    gridView1.LeftCoord = width;
                }
                width += viewInfo.ColumnsInfo[column].Bounds.Width;
            }
            if (scrollInfo.VScrollVisible)
            {
                width += scrollInfo.VScrollSize;
            }
            int height = viewInfo.CalcRealViewHeight(new Rectangle(0, 0, ClientSize.Width, ClientSize.Height), true);

            if (scrollInfo.HScrollVisible)
            {
                height += scrollInfo.HScrollSize;
            }
            width             = Math.Max(GridMinWidth, width);
            width             = Math.Min(ClientSize.Width - gridControl1.Location.X, width);
            height            = Math.Max(GridMinHeight, height);
            height            = Math.Min(ClientSize.Height - gridControl1.Location.Y, height);
            gridControl1.Size = new Size(width, height);
            gridView1.LayoutChanged();
        }
Пример #2
0
        private int GetInvisibleRowsHeight()
        {
            GridViewInfo viewInfo   = (GridViewInfo)this.gridView1.GetViewInfo();
            int          gridHeight = viewInfo.CalcRealViewHeight(new Rectangle(0, 0, int.MaxValue, int.MaxValue));

            return(gridHeight);
        }
        public int CalcGridHeight()
        {
            int          height = 0;
            GridViewInfo info   = (this.MainView as MyGridView).GetViewInfo() as GridViewInfo;

            height = info.CalcRealViewHeight(new Rectangle(0, 0, this.Width, 100000));
            if (height < ScrollableContainer.Height)
            {
                Dock = DockStyle.Fill;
            }
            else
            {
                Dock = DockStyle.Top;
            }
            return(height);
        }
Пример #4
0
 public int GetRowHeight()
 {
     if (_GridViewType == GridViewType.GridView || _GridViewType == GridViewType.BandedGridView || _GridViewType == GridViewType.AdvBandedGridView)
     {
         GridViewInfo viewInfo             = (MainView as GridView).GetViewInfo() as GridViewInfo;
         const int    GridControlMaxHeight = 30000;
         int          height = viewInfo.CalcRealViewHeight(new Rectangle(0, 0, (MainView as GridView).GridControl.Width, GridControlMaxHeight));
         if (height >= GridControlMaxHeight)
         {
             height = (MainView as GridView).GridControl.Parent.Height;
         }
         return(height);
     }
     else
     {
         return(-1);
     }
 }
Пример #5
0
        public static void BestHeightGridView(GridView gridView, int minHeight = 0, int maxHeight = 0)
        {
            GridControl  gridControl = gridView.GridControl;
            GridViewInfo viewInfo    = (GridViewInfo)gridView.GetViewInfo();
            FieldInfo    fi          = typeof(GridView).GetField("scrollInfo", BindingFlags.Instance | BindingFlags.NonPublic);
            ScrollInfo   scrollInfo  = (ScrollInfo)fi.GetValue(gridView);

            int height = viewInfo.CalcRealViewHeight(new Rectangle(0, 0, 0, maxHeight == 0 ? int.MaxValue : maxHeight));

            if (scrollInfo.HScrollVisible)
            {
                height += scrollInfo.HScrollSize;
            }

            height = Math.Max(minHeight, height);

            if (maxHeight > 0)
            {
                height = Math.Min(maxHeight - gridControl.Location.Y, height);
            }

            gridControl.Size = new Size(gridControl.Width, height);
            gridView.LayoutChanged();
        }