/// <override/> protected override void OnDraw(Graphics g, Rectangle clientRectangle, int rowIndex, int colIndex, GridStyleInfo style) { if (clientRectangle.IsEmpty) { return; } CustomGridControl grid = this.Grid as CustomGridControl; if (grid != null && grid.CenterTextInVisibleCellPart && colIndex < 3 && rowIndex > 0) { Rectangle bounds = clientRectangle; bounds.Intersect(grid.ViewLayout.RangeInfoToRectangle(GridRangeInfo.Cells(grid.TopRowIndex, 0, grid.ViewLayout.LastVisibleRow, grid.ViewLayout.LastVisibleCol), true, GridCellSizeKind.VisibleSize)); bounds.Intersect(grid.ClientRectangle); string displayText = String.Empty; Rectangle textRectangle = RemoveMargins(bounds, style); if (textRectangle.IsEmpty) { return; } displayText = style.Text; if (displayText.Length > 0) { Font font = style.GdipFont; Color textColor = Grid.PrintingMode && Grid.Model.Properties.BlackWhite ? Color.Black : style.TextColor; DrawText(g, displayText, font, textRectangle, style, textColor, false); } return; } base.OnDraw(g, clientRectangle, rowIndex, colIndex, style); }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.centerText = new Syncfusion.Windows.Forms.Tools.CheckBoxAdv(); this.panel1 = new System.Windows.Forms.Panel(); this.gridControl1 = new VirtualMergeCell.CustomGridControl(); ((System.ComponentModel.ISupportInitialize)(this.centerText)).BeginInit(); this.panel1.SuspendLayout(); this.SuspendLayout(); // // centerText // this.centerText.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.centerText.BeforeTouchSize = new System.Drawing.Size(150, 21); this.centerText.Checked = true; this.centerText.CheckState = System.Windows.Forms.CheckState.Checked; this.centerText.DrawFocusRectangle = false; this.centerText.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.centerText.Location = new System.Drawing.Point(29, 508); this.centerText.MetroColor = System.Drawing.Color.FromArgb(((int)(((byte)(27)))), ((int)(((byte)(161)))), ((int)(((byte)(226))))); this.centerText.Name = "centerText"; this.centerText.Size = new System.Drawing.Size(480, 20); this.centerText.Style = Syncfusion.Windows.Forms.Tools.CheckBoxAdvStyle.Metro; this.centerText.TabIndex = 2; this.centerText.Text = "Center text in first 3 columns of visible parts of partially visible cells"; this.centerText.ThemesEnabled = false; this.centerText.CheckStateChanged += new System.EventHandler(this.centerText_CheckStateChanged); // // panel1 // this.panel1.Controls.Add(this.centerText); this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(912, 556); this.panel1.TabIndex = 3; // // gridControl1 // this.gridControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.gridControl1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.gridControl1.CenterTextInVisibleCellPart = false; this.gridControl1.DefaultColWidth = 100; this.gridControl1.DefaultRowHeight = 18; this.gridControl1.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.gridControl1.HorizontalThumbTrack = true; this.gridControl1.Location = new System.Drawing.Point(29, 12); this.gridControl1.MetroScrollBars = true; this.gridControl1.Name = "gridControl1"; this.gridControl1.Size = new System.Drawing.Size(854, 480); this.gridControl1.SmartSizeBox = false; this.gridControl1.TabIndex = 0; this.gridControl1.Text = "gridControl1"; this.gridControl1.ThemesEnabled = true; this.gridControl1.VerticalThumbTrack = true; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.ClientSize = new System.Drawing.Size(912, 556); this.Controls.Add(this.gridControl1); this.Controls.Add(this.panel1); this.MinimumSize = new System.Drawing.Size(800, 500); this.Name = "Form1"; this.Text = "Virtual Merge Cell"; ((System.ComponentModel.ISupportInitialize)(this.centerText)).EndInit(); this.panel1.ResumeLayout(false); this.ResumeLayout(false); }