コード例 #1
0
        public GLDataGridViewContentPanel(string name, GLDataGridViewRowHeaderPanel rowheaderpanel, Rectangle location) : base(name, location)
        {
            this.rowheaderpanel    = rowheaderpanel;
            BorderColorNI          = DefaultVerticalScrollPanelBorderColor;
            BackColorGradientAltNI = BackColorNI = Color.Red;// DefaultVerticalScrollPanelBackColor;

            autoscroll.Tick += (t, tick) =>
            {
                GLDataGridView dgv = Parent as GLDataGridView;

                if (lastmousemove.Y > 0)
                {
                    //System.Diagnostics.Debug.WriteLine($"First line {dgv.FirstDisplayIndex} last complete {dgv.LastCompleteLine()}");
                    if (LastCompleteLine() < dgv.Rows.Count - 1)     // and scroll to the end, until all lines are on screen
                    {
                        dgv.FirstDisplayIndex++;
                    }
                }
                else
                {
                    if (FirstDisplayIndex > 0)
                    {
                        FirstDisplayIndex--;
                    }
                }
                UpdateSelection(lastmousemove);
            };
        }
コード例 #2
0
        /// <summary> Construct with name and bounds</summary>
        public GLDataGridView(string name, Rectangle location) : base(name, location)
        {
            int sbwidth = 16;

            vertscroll         = new GLVerticalScrollBar(name + "_VSB", new Rectangle(0, 0, sbwidth, 10), 0, 100);
            vertscroll.Dock    = DockingType.Right;
            vertscroll.Scroll += (sb, se) => { contentpanel.FirstDisplayIndex = se.NewValue; };
            horzscroll         = new GLHorizontalScrollBar(name + "_HSB", new Rectangle(0, 0, 10, sbwidth), 0, 100);
            horzscroll.Dock    = DockingType.Bottom;
            horzscroll.Scroll += (sb, se) => { colheaderpanel.HorzScroll = contentpanel.HorzScroll = se.NewValue; };
            horzscroll.Theme   = vertscroll.Theme;      // use one theme between them
            vertscroll.Theme.Parents.Add(horzscroll);

            rowheaderpanel              = new GLDataGridViewRowHeaderPanel(name + "_RHP", location);
            rowheaderpanel.Dock         = DockingType.Left;
            contentpanel                = new GLDataGridViewContentPanel(name + "_CP", rowheaderpanel, location);
            contentpanel.Dock           = DockingType.Fill;
            rowheaderpanel.contentpanel = contentpanel;
            colheaderpanel              = new GLDataGridViewColumnHeaderPanel(name + "_CHP", location);
            colheaderpanel.Dock         = DockingType.Top;
            topleftpanel                = new GLDataGridViewTopLeftHeaderPanel(name + "_TLP", location);
            topleftpanel.Dock           = DockingType.LeftTop;
            Add(contentpanel);
            Add(colheaderpanel);
            Add(rowheaderpanel);
            Add(vertscroll);
            Add(horzscroll);
            Add(topleftpanel);

            colheaderstyle.Changed   += (e1) => { colheaderpanel.Invalidate(); };
            rowheaderstyle.Changed   += (e1) => { ContentInvalidateLayout(); };
            defaultcellstyle.Changed += (e1) => { ContentInvalidateLayout(); };

            BorderColorNI                   = DefaultDGVBorderColor;
            BackColorGradientAltNI          = BackColorNI = DefaultDGVBackColor;
            cellbordercolor                 = DefaultDGVCellBorderColor;
            upperleftbackcolor              = colheaderstyle.BackColor = rowheaderstyle.BackColor = DefaultDGVColumnRowBackColor;
            colheaderstyle.ForeColor        = rowheaderstyle.ForeColor = DefaultDGVColumnRowForeColor;
            defaultcellstyle.BackColor      = DefaultDGVCellBackColor;
            defaultcellstyle.ForeColor      = DefaultDGVCellForeColor;
            colheaderstyle.SelectedColor    = rowheaderstyle.SelectedColor = defaultcellstyle.SelectedColor = DefaultDGVCellSelectedColor;
            colheaderstyle.HighlightColor   = rowheaderstyle.HighlightColor = defaultcellstyle.HighlightColor = DefaultDGVCellHighlightColor;
            colheaderstyle.ContentAlignment = rowheaderstyle.ContentAlignment = defaultcellstyle.ContentAlignment = ContentAlignment.MiddleCenter;
            colheaderstyle.TextFormat       = rowheaderstyle.TextFormat = defaultcellstyle.TextFormat = 0;
            colheaderstyle.Font             = rowheaderstyle.Font = defaultcellstyle.Font = Font;
            colheaderstyle.Padding          = rowheaderstyle.Padding = defaultcellstyle.Padding = new PaddingType(0);

            defaultaltrowcellstyle.Parent = defaultcellstyle;       // all null, uses cell style until overridden

            colheaderpanel.MouseClickColumnHeader += (col, e) =>
            {
                //System.Diagnostics.Debug.WriteLine($"Click on {col} {SortColumn} {SortAscending}");
                if (AllowUserToSortColumns)
                {
                    Sort(col, !SortAscending);
                }
                else
                {
                    MouseClickOnGrid?.Invoke(-1, col, e);
                }
            };

            topleftpanel.MouseClickColumnHeader += (e) =>
            {
                //System.Diagnostics.Debug.WriteLine($"Click on top left");
                MouseClickOnGrid?.Invoke(-2, -2, e);
            };

            rowheaderpanel.MouseClickRowHeader += (row, e) =>
            {
                //System.Diagnostics.Debug.WriteLine($"Click on row header {row}");
                MouseClickOnGrid?.Invoke(row, -1, e);
            };
            contentpanel.MouseClickOnGrid += (row, col, e) =>
            {
                //System.Diagnostics.Debug.WriteLine($"Click on grid {row} {col}");
                MouseClickOnGrid?.Invoke(row, col, e);
            };
        }