This is a migrated thread and some comments may be shown as answers.

MouseDoubleClick event handler return cell value

1 Answer 72 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dennis van Espelo
Top achievements
Rank 1
Dennis van Espelo asked on 14 Feb 2012, 03:46 PM
Hello,

I created a RadGridView and binded a dataset. While double click a row, it should popup a message with the content of the ID cell. Can someone explain how to do this?

<telerik:RadGridView ItemsSource="{Binding}" x:Name="Listing" AutoGenerateColumns="False" SelectionMode="Single" IsReadOnly="True">
     <telerik:RadGridView.Columns>
      <telerik:GridViewDataColumn Header="ID" MinWidth="25" DataMemberBinding="{Binding Path=ID}"></telerik:GridViewDataColumn> 
          <telerik:GridViewDataColumn Header="Lastname" MinWidth="150" DataMemberBinding="{Binding Path=surname}"></telerik:GridViewDataColumn>
          <telerik:GridViewDataColumn Header="Initials" MinWidth="75" DataMemberBinding="{Binding Path=initials}"></telerik:GridViewDataColumn>
     </telerik:RadGridView.Columns>
</telerik:RadGridView>

After I added an event handler

Listing.MouseDoubleClick += RadGridView1_MouseDoubleClick;

How do I show the ID of the cell clicked?

public void RadGridView1_MouseDoubleClick(object sender, RoutedEventArgs e)
 {
            MessageBox.Show("ID" + ????);
 }

1 Answer, 1 is accepted

Sort by
0
Dennis van Espelo
Top achievements
Rank 1
answered on 15 Feb 2012, 11:15 AM
After puzzling I managed to get the cell value. Not sure it's the right way to do it.

public void RadGridView1_MouseDoubleClick(object sender, MouseButtonEventArgs e) 
            DataRow Item = Listing.SelectedCells[0].Item as DataRow; 
            MessageBox.Show(Item["ID"].ToString()); 
}
Tags
GridView
Asked by
Dennis van Espelo
Top achievements
Rank 1
Answers by
Dennis van Espelo
Top achievements
Rank 1
Share this question
or