20

DataSet を使用して、WPF (C#) で DataGrid を設定します。結果は次のとおりです。

ここに画像の説明を入力

左側の空白の列を削除したい。そして、残りのスペースを列に共有したいと思います。期待される結果は次のとおりです。

ここに画像の説明を入力

私のXAMLコードは次のとおりです。

<Window x:Class="RFID.CareerWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="CareerWindow" Height="356" Width="404">
    <Grid>

        <DataGrid x:Name="dg1" HorizontalAlignment="Left" Margin="25,10,0,0" VerticalAlignment="Top" Height="306" Width="355" EnableRowVirtualization="false" EnableColumnVirtualization="false" FontFamily="2  badr" FontSize="20" FlowDirection="RightToLeft" CanUserAddRows="False" CanUserReorderColumns="False"/>

    </Grid>
</Window>
4

2 に答える 2

40

高さと幅を静的に設定することは避けてください。

ColumnWidth="*"DataGridColumns 間のスペースを共有するために使用します

<DataGrid x:Name="dg1" ColumnWidth="*"
          HorizontalAlignment="Left" VerticalAlignment="Top" Margin="25,10,0,0"
          EnableRowVirtualization="false" EnableColumnVirtualization="false" 
          FontFamily="2  badr" FontSize="20" FlowDirection="RightToLeft" 
          CanUserAddRows="False" CanUserReorderColumns="False" />
于 2013-08-13T18:04:29.237 に答える