Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

DoubleClick selected Row in DataGrid

$
0
0

Right now when I double click on a selected row in my DataGrid it populates a second datagrid with 2 rows of data instead of just the one row that is clicked. What I am trying to do is when a Row is clicked it pulls the toy information from the ToyInfo Table and then populates the second datagrid with the toy information.

<DataGrid Height="386" VerticalAlignment="Top" Width="832" ItemsSource="{Binding Path=MyDataBinding}" Name="datagrid1" BorderBrush="{x:Null}" Style="{DynamicResource DataGridStyle1}" Background="White" ColumnHeaderHeight="30" ColumnWidth="110"><DataGrid.RowStyle><Style TargetType="{x:Type DataGridRow}"><EventSetter Event="MouseDoubleClick" Handler="DataGrid_MouseDoubleClick"/></Style></DataGrid.RowStyle></DataGrid>

 private void DataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            conConnect = new SqlConnection("Data Source=GERRY;Initial Catalog=toyDB;Integrated Security=True");

            dAdapter = new SqlDataAdapter("SELECT * FROM ToyInfo", conConnect);
            DS = new DataSet();

            dAdapter.Fill(DS, "MyDataBinding");

            datagrid2.DataContext = DS;

            dAdapter.Dispose();
            conConnect.Close();

        }


Viewing all articles
Browse latest Browse all 31927

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>