Data Step between WPF Forms

0

I have the following question, I have a form with a datagrid with which I pretend that by selecting the datagrid row, I can send the datagrid information to a new form and present that information in the corresponding textbox of the New window I am using WPF I would appreciate your help.

    
asked by juan ancona 09.11.2018 в 04:53
source

1 answer

0

use the binding property, here is an example:

   <DataGrid x:Name="dgSells" HorizontalAlignment="Left" Margin="10,63,0,0" VerticalAlignment="Top" Height="267" Width="632" CanUserResizeRows="False" CanUserReorderColumns="False" Cursor="Hand" 
                                        IsReadOnly="True" Background="White" SelectedIndex="0" VerticalGridLinesBrush="{x:Null}" HorizontalGridLinesBrush="{x:Null}" AlternationCount="2" AlternatingRowBackground="#FFD7D8B9" BorderThickness="1" Foreground="Black" HeadersVisibility="Column" AutoGenerateColumns="False" BorderBrush="Black">
                                    <DataGrid.Columns>
                                        <DataGridTextColumn Binding="{Binding VentaID}" ClipboardContentBinding="{x:Null}" FontWeight="Bold" Header="VentaID" Width="85"/>
                                        <DataGridTextColumn Binding="{Binding Fecha, StringFormat=\{0:dd/MM/yy\}}" ClipboardContentBinding="{x:Null}" FontWeight="Bold" Header="Fecha" Width="85"/>
                                        <DataGridTextColumn Binding="{Binding NombreProducto}" ClipboardContentBinding="{x:Null}" FontWeight="Bold" Header="No. Parte" Width="190"/>
                                        <DataGridTextColumn Binding="{Binding OrdenCompra}" ClipboardContentBinding="{x:Null}" FontWeight="Bold" Header="Órden compra" Width="120"/>
                                        <DataGridTextColumn Binding="{Binding Cantidad}" ClipboardContentBinding="{x:Null}" FontWeight="Bold" Header="Cantidad" Width="70"/>
                                        <DataGridTextColumn Binding="{Binding PrecioPO}" ClipboardContentBinding="{x:Null}" FontWeight="Bold" Header="Precio OC" Width="91.5"/>

                                    </DataGrid.Columns>

                                </DataGrid>

     <TextBox x:Name="VentaID" Text="{Binding SelectedItem.VentaID, ElementName=dgSells, Mode=OneWay}" HorizontalAlignment="Left" Height="25" Margin="661,114,0,0" TextWrapping="Wrap"  VerticalAlignment="Top" Width="169" IsReadOnly="True"/>

In this way the textbox will take the saleID value of the selected row.
Now if your textbox fields are in a new window you will have to pass parameters to the new window, you can do it using hidden textboxes that are connected to the datagrid by using the binding property to then use that text to make the step of parameters

    
answered by 09.11.2018 в 21:19