DataGridView.DataBindingComplete Event
Occurs after a data-binding operation has finished.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
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 dataGridView1.AutoResizeColumns() End Sub
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.