HighTechTalks DotNet Forums  

DataGridViewComboBoxColumn change to automatically update DataGridView

VB.net microsoft.public.dotnet.languages.vb


Discuss DataGridViewComboBoxColumn change to automatically update DataGridView in the VB.net forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
tim8w via DotNetMonster.com
 
Posts: n/a

Default DataGridViewComboBoxColumn change to automatically update DataGridView - 01-24-2010 , 10:29 PM






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

Reply With Quote
  #2  
Old   
Cor Ligthert[MVP]
 
Posts: n/a

Default Re: DataGridViewComboBoxColumn change to automatically update DataGridView - 01-24-2010 , 10:57 PM






Most common the change index event of a combobox is used.



"tim8w via DotNetMonster.com" <u31412@uwe> wrote

Quote:
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

Reply With Quote
  #3  
Old   
tim8w via DotNetMonster.com
 
Posts: n/a

Default Re: DataGridViewComboBoxColumn change to automatically update DataGridView - 01-25-2010 , 12:33 AM



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

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

Reply With Quote
  #4  
Old   
Fred
 
Posts: n/a

Default Re: DataGridViewComboBoxColumn change to automatically update DataGridView - 01-25-2010 , 01:08 AM



"tim8w via DotNetMonster.com" <u31412@uwe> a écrit dans le message de
groupe de discussion : a29f12a6a1d99 (AT) uwe (DOT) ..
Quote:
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.currentcelldirty statechanged.aspx

--
Fred
foleide (AT) free (DOT) fr

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.