Torna al Thread

Private Sub DataGridView1_EditingControlShowing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles DataGridView1.EditingControlShowing ' Only for a DatagridComboBoxColumn at ColumnIndex 1. If DataGridView1.CurrentCell.ColumnIndex = 1 Then Dim combo As ComboBox = CType(e.Control, ComboBox) If (combo IsNot Nothing) Then ' Remove an existing event-handler, if present, to avoid ' adding multiple handlers when the editing control is reused. RemoveHandler combo.SelectionChangeCommitted, New EventHandler(AddressOf ComboBox_SelectionChangeCommitted) ' Add the event handler. AddHandler combo.SelectionChangeCommitted, New EventHandler(AddressOf ComboBox_SelectionChangeCommitted) End If End If End Sub Private Sub ComboBox_SelectionChangeCommitted(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim combo As ComboBox = CType(sender, ComboBox) Console.WriteLine("Row: {0}, Value: {1}", DataGridView1.CurrentCell.RowIndex, combo.SelectedItem) End Sub
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5