Click here to Skip to main content
16,012,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have a form ,in that form one datagridview is present.
I am using C#.net langauge.

I want to do that, when i click any row of that datagridview control,the second column's data related to selected row should pop-up in Message Box.
how can i do this
please help..........
Posted

1 solution

Handle the DataGridView.Click event:
C#
private void myDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
    {
    DataGridView dgv = sender as DataGridView;
    if (dgv != null)
        {
        DataGridViewCell cell = dgv.Rows[e.RowIndex].Cells[e.ColumnIndex];
        MessageBox.Show(cell.Value.ToString());
        }
    }
 
Share this answer
 
Comments
yogesh89 24-Oct-11 6:34am    
thanks........it worked for me..........

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900