Solved

Get Selected Item wpf datagrid

Posted on 2011-03-11
4
1,276 Views
Last Modified: 2012-05-11
WPF This should be really simple but I just can't find it. New to WPF so sorry about this.
I have a datagrid and just want to click on a cell and either show its contents in a text box or popup a messagebox with the value.
Thought it should be selectedvalue or selecteditem or something like that but have had no luck sofar.

Thanks
Cnat even find WPF zone to put this question in
0
Comment
Question by:Eamon
  • 2
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
Sudhakar Pulivarthi earned 500 total points
ID: 35108248
0
 
LVL 1

Author Comment

by:Eamon
ID: 35109813
This is how the dataGridd is filled

cmd.ExecuteNonQuery();
SqlDataAdapter daPopGRN = new SqlDataAdapter(cmd);

DataSet dsPopGRN = new DataSet();
daPopGRN.Fill(dsPopGRN, "GRN");

dgGrn.ItemsSource = dsPopGRN.Tables[0].DefaultView;
0
 
LVL 11

Expert Comment

by:Sudhakar Pulivarthi
ID: 35110378
Hi Eamon,

Here is how a solution is provided to your requirement.
http://stackoverflow.com/questions/3774140/wpf-datagrid-datatable-large-number-of-rows
0
 
LVL 1

Author Closing Comment

by:Eamon
ID: 35213587
I ended up using this.

int i = dgGrn.Items.IndexOf(dgGrn.SelectedItem);
                var rowData = dgGrn.Items[i] as DataRowView;
                ret = rowData[ColName].ToString();
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
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!
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

896 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now