Getting the value in a cell in a DataGridView

G

Greg Smith

I would like to capture the value in a specific cell in the current row on
a double-click event on a DataGridView.

I can't seem to figure out the syntax.

Any help is greatly appreciated.
 
O

Ozgur Seyrek

Well Winista referanced an article that is a java code and it didnt
give any idea to me
Here is simple way to do that,
This is my first programming attempt. if this a stupid way to do this
please inform me.
// adresses to selected row's sixth cell
string ProdID
=dataGridView1.SelectedRows[0].Cells[5].EditedFormattedValue.ToString();
// adresses to selected row's first cell
string ProdCode =
dataGridView1.SelectedRows[0].Cells[0].EditedFormattedValue.ToString();
MessageBox.Show("Product ID " + ProdID + " Product Code " + ProdCode)

Put this code under
private void dataGridView1_CellMouseDoubleClick(object sender,
DataGridViewCellMouseEventArgs e)

and it will work

Winista yazdi:
 
W

Winista

There is nothing like MessageBox.Show in ASP.Net world.

Ozgur Seyrek said:
Well Winista referanced an article that is a java code and it didnt
give any idea to me
Here is simple way to do that,
This is my first programming attempt. if this a stupid way to do this
please inform me.
// adresses to selected row's sixth cell
string ProdID
=dataGridView1.SelectedRows[0].Cells[5].EditedFormattedValue.ToString();
// adresses to selected row's first cell
string ProdCode =
dataGridView1.SelectedRows[0].Cells[0].EditedFormattedValue.ToString();
MessageBox.Show("Product ID " + ProdID + " Product Code " + ProdCode)

Put this code under
private void dataGridView1_CellMouseDoubleClick(object sender,
DataGridViewCellMouseEventArgs e)

and it will work

Winista yazdi:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top