为什么WPF DataGrid显示额外的列? [英] Why WPF DataGrid Shows an extra collumn?

查看:104
本文介绍了为什么WPF DataGrid显示额外的列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在WPF中,我正在使用以下简单网格

Hi,

In WPF, I am using simple grid as below

<Grid>
    <DataGrid Name="grid1">
        <DataGrid.Columns>
            <DataGridTextColumn Header="Col1" Width="Auto"/>
        </DataGrid.Columns>
    </DataGrid>
</Grid>



它生成col1以及一个禁用的额外collumn.我不知道为什么它会生成我尝试使用AutoGeneratese ..属性的额外列,但这不是这里的情况.仍然显示出额外的柱子

实际上,它显示了
----------------------
Col1 | ---------------
----------------------

它应该显示
----------------------
Col1 ------------------
----------------------

在此先感谢:)



It generates col1 as well as an extra collumn which is disabled. I dont know why it is generating an extra collumn I tried with AutoGeneratese.. Property but that is not a case here. Still it shows an extra collumn

Actually, it shows
----------------------
Col1 | ---------------
----------------------

It should show
----------------------
Col1------------------
----------------------

Thanks in advance :)

推荐答案

^ ]可以为您提供帮助.
This[^] could help you.


因为列的宽度不是100%,所以会有空白列.尝试将宽度设为100%,则它将不会显示.

那样尝试

because the width of the column is not 100%, thaty a blank column is coming. try to make the width as 100%, then it will not display.

Try like that

<DataGridTextColumn Header="Col1" Binding="{Binding Path=Col1}"  Width="100*"></DataGridTextColumn>


这篇关于为什么WPF DataGrid显示额外的列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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