Solved

DataGridView Selected cell C#

Posted on 2009-04-14
3
713 Views
Last Modified: 2013-12-17
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.
0
Comment
Question by:csharp_learner
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 9

Expert Comment

by:Sreedhar Vengala
ID: 24135934
to get col1 value of selected row:

var col1val = DataGriidView.Item(Column1,SelectedRow).Value;
0
 

Author Comment

by:csharp_learner
ID: 24135972
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?
0
 
LVL 9

Accepted Solution

by:
Sreedhar Vengala earned 400 total points
ID: 24136226
You can access the selected row Col1 value from button_click as follows:

       private void button1_Click(object sender, EventArgs e)
        {
            string value = dataGridView1.CurrentRow.Cells[0].Value.ToString();
        }
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question