This is a migrated thread and some comments may be shown as answers.

Get cell value on click

2 Answers 1445 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Felice
Top achievements
Rank 1
Felice asked on 16 Dec 2013, 03:24 PM
I am going mad with this. I can do it in gridview but I am battling to get it done in radGridView.

These lines are from a grid view in a winform that I should replace with a radGrid:

private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
       {
           var location = Convert.ToString(dataGridView1[e.ColumnIndex, e.RowIndex].Value);
 
           if (dataGridView1.Columns[e.ColumnIndex] is DataGridViewLinkColumn)
 
               if (e.ColumnIndex == 4)
                   Process.Start(location);
 
               else if (e.ColumnIndex == 5)
               {
                   int i = dataGridView1.CurrentCell.RowIndex;
Basically I simply ned to get the content of the cell where I perform the mouse click. How you do the equivalent of the above using a radGrid?

2 Answers, 1 is accepted

Sort by
0
Felice
Top achievements
Rank 1
answered on 17 Dec 2013, 09:16 AM
Finally I got it right:
private void radGridView1_CellClick(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
        {
            var gotIt = radGridView1.Rows[e.RowIndex].Cells[5].Value;
            MessageBox.Show(gotIt.ToString());
        }
0
Dimitar
Telerik team
answered on 19 Dec 2013, 10:29 AM
Hi Felice,

Thank you for writing.

Please note that you can access the value of the clicked cell in the CellClick event by just using the GridViewCellEventArgs instance:
void radGridView1_CellClick(object sender, GridViewCellEventArgs e)
{
    var value = e.Value;
    RadMessageBox.Show(value.ToString());
}

Let me know if you have additional questions.

Regards,
Dimitar
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Felice
Top achievements
Rank 1
Answers by
Felice
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or