在一个WPF DataGrid中删除空白列 [英] Remove the blank column in a WPF DataGrid

查看:1409
本文介绍了在一个WPF DataGrid中删除空白列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用DataSet来填充在WPF(C#)一个DataGrid。其结果是:

I use a DataSet to populate a DataGrid in WPF(c#). the result is:

我想在左侧删除空白列。我想分享remaing空间列。预期的结果是:

I want to remove blank column at left side. and I want to share remaing space to columns. expected result is:

我的XAML code是:

My XAML code is:

<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>

请帮我

推荐答案

避免设置静态的高度和宽度。

Avoid setting static Height and Width.

使用 columnWidth中=*您DataGridColumns之间共享空间

Use ColumnWidth="*" to share the space between your 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" />

这篇关于在一个WPF DataGrid中删除空白列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆