Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

DataGridView.DataBindingComplete Event

Occurs after a data-binding operation has finished.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

Public Event DataBindingComplete As DataGridViewBindingCompleteEventHandler

This event is raised when the contents of the data source change or when the value of the DataSource, DataMember, or BindingContext property changes.

Handling this event is useful, for example, to programmatically resize rows and columns based on content updates. For more information, see Sizing Options in the Windows Forms DataGridView Control.

For more information about handling events, see Consuming Events.

The following code example illustrates the use of this event. This example is part of a larger example available in the DataGridViewRowContextMenuStripNeededEventArgs class overview.

Private Sub dataGridView1_DataBindingComplete(ByVal sender As Object, _
ByVal e As DataGridViewBindingCompleteEventArgs) _
Handles dataGridView1.DataBindingComplete

    ' Hide some of the columns.
    With dataGridView1
        .Columns("EmployeeID").Visible = False
        .Columns("Address").Visible = False
        .Columns("TitleOfCourtesy").Visible = False
        .Columns("BirthDate").Visible = False
        .Columns("HireDate").Visible = False
        .Columns("PostalCode").Visible = False
        .Columns("Photo").Visible = False
        .Columns("Notes").Visible = False
        .Columns("ReportsTo").Visible = False
        .Columns("PhotoPath").Visible = False
    End With

    ' Disable sorting for the DataGridView.
    Dim i As DataGridViewColumn
    For Each i In dataGridView1.Columns
        i.SortMode = DataGridViewColumnSortMode.NotSortable
    Next i


End Sub

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

© 2015 Microsoft