Get cell value on click

3 posts, 0 answers
  1. Felice
    Felice avatar
    198 posts
    Member since:
    Aug 2013

    Posted 16 Dec 2013 Link to this post

    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. Felice
    Felice avatar
    198 posts
    Member since:
    Aug 2013

    Posted 17 Dec 2013 Link to this post

    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());
            }
  3. Dimitar
    Admin
    Dimitar avatar
    2913 posts

    Posted 19 Dec 2013 Link to this post

    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 >>
Back to Top