Disabling or greying out a DataGridView

Private Sub DataGridView1_EnabledChanged(sender As Object, e As EventArgs) Handles DataGridView1.EnabledChanged
    If Not DataGridView1.Enabled Then
        DataGridView1.DefaultCellStyle.BackColor = SystemColors.Control
        DataGridView1.DefaultCellStyle.ForeColor = SystemColors.GrayText
        DataGridView1.ColumnHeadersDefaultCellStyle.BackColor = SystemColors.Control
        DataGridView1.ColumnHeadersDefaultCellStyle.ForeColor = SystemColors.GrayText
        DataGridView1.CurrentCell = Nothing
        DataGridView1.ReadOnly = True
        DataGridView1.EnableHeadersVisualStyles = False
    Else
        DataGridView1.DefaultCellStyle.BackColor = SystemColors.Window
        DataGridView1.DefaultCellStyle.ForeColor = SystemColors.ControlText
        DataGridView1.ColumnHeadersDefaultCellStyle.BackColor = SystemColors.Window
        DataGridView1.ColumnHeadersDefaultCellStyle.ForeColor = SystemColors.ControlText
        DataGridView1.ReadOnly = False
        DataGridView1.EnableHeadersVisualStyles = True
    End If
End Sub

Simple answer to your question: no, there isn't a better way.

MSDN is mostly silent on the topic but the forums are abuzz. Manually setting the background colour to Gray is how most people get "disabled" look on the DGV.


sveilleux2's example, only in C# (which is the tag) and advanced (allows you to put it on any name and on any number of DataGridViews)

private void DataGridView_EnabledChanged(object sender, EventArgs e)
    {
        DataGridView dgv = sender as DataGridView;
        if (!dgv.Enabled) {
            dgv.DefaultCellStyle.BackColor = SystemColors.Control;
            dgv.DefaultCellStyle.ForeColor = SystemColors.GrayText;
            dgv.ColumnHeadersDefaultCellStyle.BackColor = SystemColors.Control;
            dgv.ColumnHeadersDefaultCellStyle.ForeColor = SystemColors.GrayText;
            dgv.CurrentCell = null;
            dgv.ReadOnly = true;
            dgv.EnableHeadersVisualStyles = false;
        }
        else {
            dgv.DefaultCellStyle.BackColor = SystemColors.Window;
            dgv.DefaultCellStyle.ForeColor = SystemColors.ControlText;
            dgv.ColumnHeadersDefaultCellStyle.BackColor = SystemColors.Window;
            dgv.ColumnHeadersDefaultCellStyle.ForeColor = SystemColors.ControlText;
            dgv.ReadOnly = false;
            dgv.EnableHeadersVisualStyles = true;
        }
    }