public BGridView() { panel = new Panel(); panel.Dock = DockStyle.Fill; panelBotton = new Panel(); panelBotton.Dock = DockStyle.Bottom; panelRight = new Panel(); panelRight.Dock = DockStyle.Right; panelRight.Width = 15; panelBotton.Height = 15; panelFill = new Panel(); panelFill.Dock = DockStyle.Fill; //panelFill.Padding = new System.Windows.Forms.Padding(0, 0, 0, 15); HBar = new BScrollbar(); VBar = new BScrollbar(); HBar.IsVScroll = false; HBar.Dock = DockStyle.Bottom; HBar.MinimumSize = new System.Drawing.Size(20, 0); HBar.Height = 15; HBar.Value = 0; VBar.IsVScroll = true; VBar.Dock = DockStyle.Right; VBar.Width = 15; VBar.Value = 0; VBar.ChannelColor = HBar.ChannelColor = Color.FromArgb(90, 90, 90); VBar.ThumbColor = HBar.ThumbColor = Color.FromArgb(215, 215, 215); panelBotton.Controls.Add(HBar); panelRight.Controls.Add(VBar); //panel.Controls.Add(this); VBar.Scroll += VBar_Scroll; HBar.Scroll += HBar_Scroll; this.MouseWheel += BGridView_MouseWheel; this.DataBindingComplete += BGridView_DataBindingComplete; this.ParentChanged += BGridView_ParentChanged; this.Resize += BGridView_Resize; this.ScrollBars = ScrollBars.Both; this.AutoGenerateColumns = false; this.Dock = DockStyle.Fill; // // dataGridView1 // System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); this.AllowUserToAddRows = false; this.AllowUserToDeleteRows = false; this.AllowUserToResizeRows = false; this.BackgroundColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20))))); this.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; this.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single; dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(91)))), ((int)(((byte)(91)))), ((int)(((byte)(91))))); dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); //dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(205)))), ((int)(((byte)(205)))), ((int)(((byte)(205))))); dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; this.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; this.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.Dock = System.Windows.Forms.DockStyle.Fill; this.EnableHeadersVisualStyles = false; this.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(77)))), ((int)(((byte)(77)))), ((int)(((byte)(77))))); this.Location = new System.Drawing.Point(0, 0); this.Name = "dataGridView1"; this.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single; dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; dataGridViewCellStyle2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(91)))), ((int)(((byte)(91)))), ((int)(((byte)(91))))); dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); //dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(205)))), ((int)(((byte)(205)))), ((int)(((byte)(205))))); dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight; dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText; dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True; this.RowHeadersDefaultCellStyle = dataGridViewCellStyle2; this.RowHeadersVisible = false; dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20))))); dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); //dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(205)))), ((int)(((byte)(205)))), ((int)(((byte)(205))))); dataGridViewCellStyle3.SelectionBackColor = Color.FromArgb(15, 58, 93); this.RowsDefaultCellStyle = dataGridViewCellStyle3; this.RowTemplate.Height = 23; this.ScrollBars = System.Windows.Forms.ScrollBars.None; this.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.ShowCellToolTips = false; this.ShowEditingIcon = false; this.Size = new System.Drawing.Size(150, 150); this.MultiSelect = false; base.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true); }
public BGridViewContorl() : base() { HBar = new BScrollbar(); VBar = new BScrollbar(); HBar.IsVScroll = false; //HBar.Dock = DockStyle.Bottom; HBar.MinimumSize = new System.Drawing.Size(0, 0); VBar.MinimumSize = new System.Drawing.Size(0, 0); HBar.Height = 17; HBar.Value = 0; VBar.IsVScroll = true; //VBar.Dock = DockStyle.Right; //VBar.Anchor = AnchorStyles.Right; VBar.Width = 17; VBar.Value = 0; VBar.ChannelColor = HBar.ChannelColor = Color.FromArgb(90, 90, 90); VBar.ThumbColor = HBar.ThumbColor = Color.FromArgb(215, 215, 215); // VBar.Margin = new Padding(0, 0, -18, 0); this.Controls.Add(HBar); this.Controls.Add(VBar); CheckForIllegalCrossThreadCalls = false; this.ScrollBars = ScrollBars.Both; this.AutoGenerateColumns = false; this.Dock = DockStyle.Fill; // // dataGridView1 // System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); this.AllowUserToAddRows = false; this.AllowUserToDeleteRows = false; this.AllowUserToResizeRows = false; this.BackgroundColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20))))); this.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; this.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single; dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(91)))), ((int)(((byte)(91)))), ((int)(((byte)(91))))); dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(205)))), ((int)(((byte)(205)))), ((int)(((byte)(205))))); dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; this.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; this.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.ColumnHeadersHeight = 20; this.Dock = System.Windows.Forms.DockStyle.Fill; this.EnableHeadersVisualStyles = false; this.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(77)))), ((int)(((byte)(77)))), ((int)(((byte)(77))))); this.Location = new System.Drawing.Point(0, 0); this.Name = "dataGridView1"; this.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single; dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; dataGridViewCellStyle2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(91)))), ((int)(((byte)(91)))), ((int)(((byte)(91))))); dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); //dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(205)))), ((int)(((byte)(205)))), ((int)(((byte)(205))))); dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight; dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText; dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True; this.RowHeadersDefaultCellStyle = dataGridViewCellStyle2; this.RowHeadersVisible = false; dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20))))); dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(205)))), ((int)(((byte)(205)))), ((int)(((byte)(205))))); dataGridViewCellStyle3.SelectionBackColor = Color.FromArgb(15, 58, 93); this.RowsDefaultCellStyle = dataGridViewCellStyle3; this.RowTemplate.Height = 23; //this.ScrollBars = System.Windows.Forms.ScrollBars.None; this.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.ShowCellToolTips = false; this.ShowEditingIcon = false; this.Size = new System.Drawing.Size(150, 150); this.MultiSelect = false; base.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true); this.HorizontalScrollBar.VisibleChanged += new EventHandler(ScrollBar_VisibleChanged); this.VerticalScrollBar.VisibleChanged += new EventHandler(ScrollBar_VisibleChanged); this.SizeChanged += new EventHandler(ScrollBar_VisibleChanged); this.VBar.ValueChanged += new EventHandler(VScrollBarEx_ValueChanged); HBar.ValueChanged += new EventHandler(HScrollBarEx_ValueChanged); this.Scroll += new ScrollEventHandler(DataGridViewEx_Scroll); this.ColumnHeadersHeightChanged += new EventHandler(ScrollBar_VisibleChanged); this.ColumnWidthChanged += new DataGridViewColumnEventHandler(ScrollBar_VisibleChanged); this.RowHeadersWidthChanged += new EventHandler(ScrollBar_VisibleChanged); this.RowHeightChanged += new DataGridViewRowEventHandler(ScrollBar_VisibleChanged); this.RowsAdded += new DataGridViewRowsAddedEventHandler(ScrollBar_VisibleChanged); this.RowsRemoved += new DataGridViewRowsRemovedEventHandler(ScrollBar_VisibleChanged); this.ColumnAdded += new DataGridViewColumnEventHandler(ScrollBar_VisibleChanged); //this.ColumnAdded+=BGridViewContorl_ColumnAdded; this.ColumnRemoved += new DataGridViewColumnEventHandler(ScrollBar_VisibleChanged); this.DataSourceChanged += new EventHandler(ScrollBar_VisibleChanged); this.ColumnDisplayIndexChanged += BGridViewContorl_ColumnDisplayIndexChanged; this.RowPostPaint += BGridViewContorl_RowPostPaint; this.DataBindingComplete += BGridViewContorl_DataBindingComplete; SetScrollBarEx(); }