Socarsky
Well-known member
Which code line or any property of DataGridView caused not to see <No Data to Display> string in the middle of DataGridView with its property of paint?
Here the code:
If I use a simple DataGridView then I can see the feature like below
Here the code:
Private Sub SetUpDataGridView() Me.Controls.Add(DataGridView1) With DataGridView1.ColumnHeadersDefaultCellStyle .BackColor = Color.Navy .ForeColor = Color.White .Font = New Font(DataGridView1.Font, FontStyle.Bold) End With With DataGridView1 .AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders .ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Raised .CellBorderStyle = DataGridViewCellBorderStyle.Single .AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells .GridColor = SystemColors.ActiveBorder .Font = New Font("Franklin Gothic Book", DataGridView1.DefaultCellStyle.Font.Size * 1 * 0.95, FontStyle.Regular, GraphicsUnit.Point) .RowHeadersVisible = False .SelectionMode = DataGridViewSelectionMode.FullRowSelect .MultiSelect = False .BackgroundColor = Color.Honeydew End With End Sub
Private Sub DataGridView1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles DataGridView1.Paint If DataGridView1.RowCount = 0 Then Using brsh As New SolidBrush(Color.DarkBlue) Using fmt As New StringFormat Dim drawFont As New Font("Arial", 16) fmt.Alignment = StringAlignment.Center e.Graphics.DrawString("<No data to display>", drawFont, brsh, DataGridView1.Left + (DataGridView1.Width / 2), DataGridView1.Top + (DataGridView1.Height / 2), fmt) End Using End Using End If End Sub
If I use a simple DataGridView then I can see the feature like below