DataGridView1.CurrentCell.Value
-
Friday, June 06, 2008 10:00 PM
Quick question - I use the code "DataGridView1.CurrentCell.Value" to do query searches. My issue is that I need to select the actual cell information. If I select just the cell not the information in the cell nothing happens.
Is there a way so that I can select the cell and the contents are taken out of if?
Thanks
All Replies
-
Friday, June 06, 2008 10:32 PMMaybe instead of posting little bits and pieces of your code you can post your code or an example of what your doing and how .
-
Friday, June 06, 2008 10:33 PM
You can use the CellContentClick event
//C#
private
void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e){
string value = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();}
//VB
Private Sub dataGridView1_CellContentClick(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs)
Dim value As String = dataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value.ToString()
End Sub -
Friday, June 06, 2008 10:45 PMUm this is the VBE forum is it not ? That looks like C# .
-
Tuesday, June 10, 2008 3:14 PM
Actually he did both C# and VB.
thanks for the code I will try it out now!

