Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

How to get DataGridViewComboBoxColumn's selected value for validation?

$
0
0

Hi.

I have a bound DataGridView with a DataGridViewComboBoxColumn. I want to validate the value the user selects.  I'm working in the grid's CellValidating() event handler. How do I get the newly selected value of the item selected in the combobox?  

In the grid's CellValidating() event handler the DataGridViewCellValidatingEventArgs "e" parameter gives me the previous combobox value which is useless in this case. I need the newly selected value for validation.

 Here's code from CellValidating:

int iVaseTypeID = (int)this.dataGridViewFlowers.Rows[e.RowIndex].Cells["datagridviewcomboboxcolumn_VaseType"].Value;

The iVaseTypeID value I get is the one from previously selected combobox item, not the value of the item currently shown in the list (the item the user selected).

A few lines of sample code would be appreciated.  Thanks!

 


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>