Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

DataGridView Selected cell C#

Posted on 2009-04-14
3
Medium Priority
?
736 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 1600 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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!
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.
Suggested Courses

604 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