PC Review


Reply
Thread Tools Rate Thread

DataGridViewComboBoxColumn change events

 
 
B. Chernick
Guest
Posts: n/a
 
      25th Sep 2008
I have a Winforms app with a datagridview control (Dot Net 2.0) One column
is a bound combobox.

What I would like to do is if the combo box is changed to a certain value,
change the value of another cell in the same current row. What I have so far
is some code in the CurrentCellDirtyStateChanged event. This works, but the
event only fires when the cell with combobox is exited.

Is there a way to do this without leaving the combobox cell?

(So far every method I've tried has required leaving the cell and/or row.)
 
Reply With Quote
 
 
 
 
Jibesh
Guest
Posts: n/a
 
      3rd Oct 2008
Chernick,

Can you please try the following code. Let me if its working you.
COLUMN_COMBO_SELECTION = your combo column id

private void dataGridView_CurrentCellDirtyStateChanged(object sender,
EventArgs e)

{

if( this.dataGridView.CurrentCell.ColumnIndex == COLUMN_COMBO_SELECTION) {

this.dataGridView.EndEdit();

}

private void dataGridView_CellValueChanged(object sender,
DataGridViewCellEventArgs e)

{

if (e.RowIndex != -1 && e.ColumnIndex == COLUMN_COMBO_SELECTION)

{

string comboText = this.dataGridView.CurrentCell.Value.ToString();

switch (comboText)

{

case "Text1":

this.dataGridView[COLUMN_NEXT, e.RowIndex].Value = "Default Text";

break;

}

}



Thanks

Jibesh

"B. Chernick" <(E-Mail Removed)> wrote in message
news:47A9A668-15A4-4946-ABCE-(E-Mail Removed)...
>I have a Winforms app with a datagridview control (Dot Net 2.0) One column
> is a bound combobox.
>
> What I would like to do is if the combo box is changed to a certain value,
> change the value of another cell in the same current row. What I have so
> far
> is some code in the CurrentCellDirtyStateChanged event. This works, but
> the
> event only fires when the cell with combobox is exited.
>
> Is there a way to do this without leaving the combobox cell?
>
> (So far every method I've tried has required leaving the cell and/or row.)



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: DataGridViewComboBoxColumn change to automatically update DataGridView Fred Microsoft VB .NET 0 25th Jan 2010 07:08 AM
Re: DataGridViewComboBoxColumn change to automatically update DataGridView Cor Ligthert[MVP] Microsoft VB .NET 0 25th Jan 2010 04:57 AM
single events change to recurring events without a prompt. =?Utf-8?B?VFBEYXZpZHNvbg==?= Microsoft Outlook Calendar 0 12th Feb 2007 04:48 AM
How to change a DataGridViewTextBoxColumn to a DataGridViewComboBoxColumn? nvx Microsoft Dot NET Framework Forms 3 25th Jul 2006 02:44 PM
Hook events in Compact framework to monitor screen change events =?Utf-8?B?bGVpZ2h0b25y?= Microsoft Dot NET Compact Framework 4 21st Feb 2006 07:40 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:50 AM.