Read a value of Datgrid cell...  
Author Message
IamHuM





PostPosted: Windows Forms Data Controls and Databinding, Read a value of Datgrid cell... Top

Hi,

How i can read a value of a cell in DataGridView...

I have 2 different types of columns in my application . If user selects values of all the 2 columns of 1st row & then he presses a button...so on that button click event i have to display value on my form using 3 lables. My columns are of textbox(1st column) & combobox(2nd column) type.

So how i can read these user selected values & display it on form with lable on button click event...

Thanks in advance,

Vinay



Windows Forms2  
 
 
ahmedilyas





PostPosted: Windows Forms Data Controls and Databinding, Read a value of Datgrid cell... Top

well you can read the values by accessing the row index and cell columnName/Index:

MessageBox.Show(this.theDataGridView.Rows[index].Cells[ColumnName].Value.ToString());

but now in order to go through each row/cell they chose, take a look at the SelectedRows and SelectedCells property, then perhaps go through each cell they chose/each row they chose and show the value



 
 
vinay.p





PostPosted: Windows Forms Data Controls and Databinding, Read a value of Datgrid cell... Top

Thanks for your immediate reply...

Can i select 1st value of each cell in my comboxcolumn on loading of form... I want user to see the 1st value of each cell in my ComboBoxColumn when he loads that form...

Thanks once agagin...

Vinay