From: tim8w via DotNetMonster.com on
I have a standard DataGridView. One of the columns is a
DataGridViewComboBoxColumn. When I select one of the ComboBox items, I want
to trap the change and add additional columns based on the item selected in
the ComboBox. I've tried using CellValueChanged for the DataGridView column,
and a bunch of other events, but none of them is fired when the
DataGridViewComboBox value is changed. What event can I trap to make this
happen? Right now as I said, I am using CellValueChanged, but of course the
event doesn't fire until I click on another cell...

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/Forums.aspx/dotnet-vb-net/201001/1

From: Cor Ligthert[MVP] on
Most common the change index event of a combobox is used.



"tim8w via DotNetMonster.com" <u31412(a)uwe> wrote in message
news:a29f12a6a1d99(a)uwe...
> I have a standard DataGridView. One of the columns is a
> DataGridViewComboBoxColumn. When I select one of the ComboBox items, I
> want
> to trap the change and add additional columns based on the item selected
> in
> the ComboBox. I've tried using CellValueChanged for the DataGridView
> column,
> and a bunch of other events, but none of them is fired when the
> DataGridViewComboBox value is changed. What event can I trap to make this
> happen? Right now as I said, I am using CellValueChanged, but of course
> the
> event doesn't fire until I click on another cell...
>
> --
> Message posted via DotNetMonster.com
> http://www.dotnetmonster.com/Uwe/Forums.aspx/dotnet-vb-net/201001/1
>
From: tim8w via DotNetMonster.com on
Cor Ligthert,
That won't work. Don't have access to it. Here's what I had to end up doing:

[CODE]
Private Sub dgvClass_EditingControlShowing(ByVal sender As Object, ByVal
e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles
dgvClass.EditingControlShowing
If TypeOf e.Control Is ComboBox Then
Dim combo As ComboBox = DirectCast(e.Control, ComboBox)

If combo IsNot Nothing Then
RemoveHandler combo.SelectedIndexChanged, _
New EventHandler(AddressOf ComboBox_SelectedIndexChanged)


AddHandler combo.SelectedIndexChanged, AddressOf
ComboBox_SelectedIndexChanged
End If
End If
End Sub
[/CODE]

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/Forums.aspx/dotnet-vb-net/201001/1

From: Fred on


"tim8w via DotNetMonster.com" <u31412(a)uwe> a écrit dans le message de
groupe de discussion : a29f12a6a1d99(a)uwe...
> I have a standard DataGridView. One of the columns is a
> DataGridViewComboBoxColumn. When I select one of the ComboBox items, I
> want
> to trap the change and add additional columns based on the item
> selected in
> the ComboBox. I've tried using CellValueChanged for the DataGridView
> column,
> and a bunch of other events, but none of them is fired when the
> DataGridViewComboBox value is changed. What event can I trap to make
> this
> happen? Right now as I said, I am using CellValueChanged, but of
> course the
> event doesn't fire until I click on another cell...

You can have a look at this event : CurrentCellDirtyStateChanged
In the event handler, you can call CommitEdit or EndEdit.

http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.currentcelldirtystatechanged.aspx

--
Fred
foleide(a)free.fr