Solved

Get Selected Item wpf datagrid

Posted on 2011-03-11
4
1,274 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

757 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

18 Experts available now in Live!

Get 1:1 Help Now