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

how to retrieve cell contents

3 Answers 70 Views
GridView
This is a migrated thread and some comments may be shown as answers.
LEONARD
Top achievements
Rank 1
LEONARD asked on 11 Jun 2014, 03:54 PM
I'm using VS2010 and VB for winforms.
The grid is being populated in an unbound mode.
In columns 0 and 1 (which the user cannot see), I have displayed a key value.

If the user clicks on a row, I want to capture the value in column 0 and column 1 and query the database.
The results are then displayed in a form.

Can you please guide me how to capture the values in the columns.
Each time the user clicks on a new row the values change.

Thank you
Leonard

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 12 Jun 2014, 06:37 AM
Hi Leonard,

Thank you for writing.

When the user selects a row, it becomes current. You can access the latter via the CurrentRow property of RadGridView. Then, you can access its cell collection and the cells values. Here is an example:
radGridView1.CurrentRow.Cells(0).Value
//or
radGridView1.CurrentRow.Cells("YourFirstColumnName").Value

More information about accessing cells is available here: http://www.telerik.com/help/winforms/gridview-cells-accessing-cells.html.

I hope that the provided information addresses your question.

Regards,
Stefan
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
LEONARD
Top achievements
Rank 1
answered on 12 Jun 2014, 01:13 PM
Thank you for the information.
2 more questions:

1: If the user clicks in column 2 I want to be able to pop up a new form.
Could you please email how to determine if the click is in column 2?

2: I want to make the back color for column 2 to be yellow.
Could you please email how to display column 2, with a backcolor = yellow.


0
Stefan
Telerik team
answered on 12 Jun 2014, 02:44 PM
Hi Leonard,

Here are the answers to your questions:

1. You can use the CurrentCellChanged event of the control, which will get triggered when the user clicks a cell. In it you can check if the CurrentColumn is the desired one.

2. You can use the CellFormatting event as advised in the other thread of yours.

Here you can find the RadGridView documentation where you can find quick answers to most of your questions: http://www.telerik.com/help/winforms/gridview-overview.html

I hope this helps.

Regards,
Stefan
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
GridView
Asked by
LEONARD
Top achievements
Rank 1
Answers by
Stefan
Telerik team
LEONARD
Top achievements
Rank 1
Share this question
or