get cell value X column index and current row index

14 posts, 1 answers
  1. anh
    anh avatar
    13 posts
    Member since:
    Nov 2010

    Posted 15 Nov 2010 Link to this post

    Hello,

    I am stuck at this part for hours and not able to find an answer on how to do this. I am can do this with the normal gridview but not with radGridView.

    I have a radGridView with 7 columns. And I want to get the cell value of the 6th column base on the row index of a double click. Because sometimes I click on column 2..but I don't want the cell value of column 2. I want the cell value of column 6.

    Please help...Thanks...

  2. Answer
    Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 15 Nov 2010 Link to this post

    Hello,

    Just do the following to get the value from a specific row:
    void radGridView1_CellDoubleClick(object sender, GridViewCellEventArgs e)
    {
        var value = radGridView1.Rows[1].Cells[6].Value;
    }

    Or for the current row:
    void radGridView1_CellDoubleClick(object sender, GridViewCellEventArgs e)
    {
        var value = radGridView1.Rows[e.RowIndex].Cells[6].Value;
    }

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga
    Telerik WinForms MVP
  3. UI for WinForms is Visual Studio 2017 Ready
  4. anh
    anh avatar
    13 posts
    Member since:
    Nov 2010

    Posted 15 Nov 2010 Link to this post

    Hello Emanuel Varga

    I just figured out that radGridView uses Row Index and Cell instead of Column Index. And now your reply confirm my findings that it's the Cells that I want to reference instead of the Column.

    I do have another problem that I can't seem to figure out. Can you help me with it? Here's the link.

    http://www.telerik.com/community/forums/winforms/combobox-and-listbox/bind-image-to-a-databind-combobox.aspx

  5. regina
    regina avatar
    40 posts
    Member since:
    Sep 2012

    Posted 28 Jan 2011 Link to this post

    also rowindex is not part e.
    but this is good way to do it that worked for me.

    Dim cell As Telerik.WinControls.UI.GridDataCellElement = TryCast(sender, Telerik.WinControls.UI.GridDataCellElement)
    Dim value= RadGridView1.Rows(cell.RowIndex).Cells(5).Value)
  6. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 02 Feb 2011 Link to this post

    Hi regina,

    I am glad to hear that you have found a way solve your issue. I just want to mention that RowIndex comes from the event arguments in the CellDoubleClick event, just like Emanuel mentioned. Note that the discussed version of RadControls for WinForms here is Q3 2010.

    Should you have any other questions, do not hesitate to contact us.
     
    All the best,
    Stefan
    the Telerik team
    Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
  7. regina
    regina avatar
    40 posts
    Member since:
    Sep 2012

    Posted 02 Feb 2011 Link to this post

    Stefan,
    You are right, I blame haste makes waste, missed it the first time I looked.
    r.
  8. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 07 Feb 2011 Link to this post

    Hi regina,

    I am glad that it worked for you. Let me know if you need anything else.
     
    Kind regards,
    Stefan
    the Telerik team
    Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
  9. Lourival de Souza Junior
    Lourival de Souza Junior avatar
    2 posts
    Member since:
    Feb 2010

    Posted 16 Feb 2012 Link to this post

    I'm spent many ours too on this simple thing, but with RadGrid for asp.net. What is the equivalent instrucion to get a cell value of a selectted row on a server side?

    I using a demo version and if i can´t figure out this i will change to other asp.net control pack. Some things here a so complicated.

    Tks,
    Lourival.
  10. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 21 Feb 2012 Link to this post

    Hi Lourival,

    Thank you for writing. 

    Please note that this forum concerns RadGridView for WinForms rather than RadGridView for ASP.NET AJAX. Please address your question in the appropriate forum, where you can get your answer.
     
    All the best,
    Stefan
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  11. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 22 Feb 2012 Link to this post

    Hello Lourival,

    Try the following code.
    C#:
    protected void grid_ItemDataBound(object sender, GridItemEventArgs e)
    {
       if (e.Item is GridDataItem)
       {
          GridDataItem item = (GridDataItem)e.Item;
          TableCell cell = (TableCell)item["UniqueName"];
       }
    }
    Also check the following help documentation.
    Accessing Cells and Rows.

    -Shinu.
  12. Carlos
    Carlos avatar
    13 posts
    Member since:
    Apr 2015

    Posted 27 May 2015 in reply to Emanuel Varga Link to this post

    In Radgrid there is no Rows properties. so how could u just write this radGridView1.Rows[e.RowIndex].Cells[6].Value ?
  13. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 28 May 2015 Link to this post

    Hello Carlos,

    Please note that this forum concerns Telerik UI for WinForms, and the RadGridView control in it, has Rows property with an indexer.

    I hope this helps.

    Regards,
    Stefan
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  14. Anusha
    Anusha avatar
    1 posts
    Member since:
    Sep 2016

    Posted 16 Sep Link to this post

    Hi Team, Im trying to automate one win form application which has many radgrid's. Im unable to locate the element using either  C# or white automation tool. Please provide your suggestions
  15. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    712 posts

    Posted 20 Sep Link to this post

    Hi Anusha,

    Thank you for writing.

    RadGridView is virtualized and its cell and row elements cannot be accessed by index because the control reuses its visual elements. Please refer to the following documentation articles: Accessing Cells, CellFormatting, RowFormatting. You can handle the events at run-time and add you custom logic there.

    I also understand that you might be trying to use an automation tool .Could you please open up a support ticket and provide us with details of what you would like to accomplish and a sample of the grid you would like to test?

    I hope this information was useful. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms. For more information check out this blog post and share your thoughts.
Back to Top
UI for WinForms is Visual Studio 2017 Ready