我使用wpf,c#创建了一个数据网格。 单独的窗口用于将数据插入数据网格。单击保存按钮后,数据网格不会更新。如果我们关闭或刷新窗口,网格将更新。
<DataGrid x:Name="dgTrnDetails" AutoGenerateColumns="False" IsReadOnly="True" HorizontalAlignment="Left" Margin="227,124,0,0" VerticalAlignment="Top" Height="380" Width="1104" >
<DataGrid.FontSize>
16
</DataGrid.FontSize>
<DataGrid.FontFamily>
<FontFamily>Arial</FontFamily>
</DataGrid.FontFamily>
<DataGrid.Columns>
<DataGridTextColumn Header="TRN Number" Binding="{Binding TRNNO}"/>
<DataGridTextColumn Header="Supplier" Binding="{Binding Supplier}"/>
<DataGridTextColumn Header="Customer" Binding="{Binding Customer}"/>
<DataGridTextColumn Header="Vehicle" Binding="{Binding Vehicle}"/>
<DataGridTextColumn Header="Driver" Binding="{Binding Driver}"/>
<DataGridTextColumn Header="Status" Binding="{Binding Status}"/>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button x:Name="AddButton" Content="Edit" Click="btnEditTrn_Click"></Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
答案 0 :(得分:1)