Link to home
Start Free TrialLog in
Avatar of csharp_learner
csharp_learnerFlag for Singapore

asked on

DataGridView Selected cell C#

Hi, this is my first time dealing with selected cell in the datagridview.

My scenario is I have a datagridview1 which read from a Oracle database.
It'll list out the data inisde the selected item(so i might have 2 rows or 6 rows depending on the selected data.)

My question is can I make it in a way the user selects a row and press a button then it'll pass the value of column 1 inisde the selected row of datagridview1 So I can use it in another function.Something like Selected.Tag in treeview.

I'd appreciate if you could tell me which event to use.Thanks.
Avatar of Sreedhar Vengala
Sreedhar Vengala
Flag of Australia image

to get col1 value of selected row:

var col1val = DataGriidView.Item(Column1,SelectedRow).Value;
Avatar of csharp_learner

ASKER

Thanks for your reply,

Do I need to bind the datagridview to an event for this?
I'm letting the user to use the click button, So how can i access to the
"var col1val = DataGriidView.Item(Column1,SelectedRow).Value;"
from the button_click function?
ASKER CERTIFIED SOLUTION
Avatar of Sreedhar Vengala
Sreedhar Vengala
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial