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

get cell value X column index and current row index

13 Answers 2515 Views
GridView
This is a migrated thread and some comments may be shown as answers.
anh
Top achievements
Rank 1
anh asked on 15 Nov 2010, 06:55 AM

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...

13 Answers, 1 is accepted

Sort by
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 15 Nov 2010, 07:49 AM
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
0
anh
Top achievements
Rank 1
answered on 15 Nov 2010, 04:30 PM

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

0
regina
Top achievements
Rank 1
answered on 28 Jan 2011, 08:36 PM
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)
0
Stefan
Telerik team
answered on 02 Feb 2011, 04:27 PM
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.
0
regina
Top achievements
Rank 1
answered on 02 Feb 2011, 04:37 PM
Stefan,
You are right, I blame haste makes waste, missed it the first time I looked.
r.
0
Stefan
Telerik team
answered on 07 Feb 2011, 01:29 PM
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.
0
Lourival de Souza Junior
Top achievements
Rank 1
answered on 16 Feb 2012, 04:32 PM
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.
0
Stefan
Telerik team
answered on 21 Feb 2012, 12:06 PM
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 >>
0
Shinu
Top achievements
Rank 2
answered on 22 Feb 2012, 08:31 AM
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.
0
Carlos
Top achievements
Rank 1
answered on 27 May 2015, 09:43 AM
In Radgrid there is no Rows properties. so how could u just write this radGridView1.Rows[e.RowIndex].Cells[6].Value ?
0
Stefan
Telerik team
answered on 28 May 2015, 06:44 AM
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
0
Anusha
Top achievements
Rank 1
answered on 16 Sep 2016, 09:00 AM
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
0
Hristo
Telerik team
answered on 20 Sep 2016, 04:23 PM
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.
Tags
GridView
Asked by
anh
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
anh
Top achievements
Rank 1
regina
Top achievements
Rank 1
Stefan
Telerik team
Lourival de Souza Junior
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Carlos
Top achievements
Rank 1
Anusha
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or