Link to home
Start Free TrialLog in
Avatar of Eamon
EamonFlag for Ireland

asked on

Get Selected Item wpf datagrid

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
ASKER CERTIFIED SOLUTION
Avatar of Sudhakar Pulivarthi
Sudhakar Pulivarthi
Flag of India 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
Avatar of Eamon

ASKER

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;
Avatar of Eamon

ASKER

I ended up using this.

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