开发者

WPF datagrid question

开发者 https://www.devze.com 2022-12-20 05:41 出处:网络
I have a WPF datagrid and it works great but I notice some sort of very tiny column before the first column ...I want to remove it ....How do I do it ?

I have a WPF datagrid and it works great but I notice some sort of very tiny column before the first column ...I want to remove it ....How do I do it ?

Take a look at the picture: http://i45.tinypic.com/2d177f9.jpg ...the thing I want to remove is what I surrounded in the red开发者_StackOverflow中文版 rectangle.


That's the row header. When you click on it, it selects the whole row. By default it looks like a weird artifact like you mentionned.

Just set the property like this RowHeaderWidth="0" and it will disappear, or set it to bigger to see it better.


It's the row header as David Brunelle said. But instead of setting it's width to zero, I think cleaner solution is to set HeadersVisibility="Column".


     <my:DataGrid HorizontalAlignment="Left" Margin="0,0,0,0" Padding="0,0,0,0" Name="softwareTable" Width="542" AutoGenerateColumns="false" CanUserAddRows="False" CanUserDeleteRows="False" IsReadOnly="True" CanUserResizeRows="False">
                <my:DataGrid.Columns>
                    <my:DataGridTextColumn Header="Name" Binding="{Binding Path=Name}" Width="182" CanUserResize="False" CanUserSort="False" CanUserReorder="False"></my:DataGridTextColumn>
                    <my:DataGridTextColumn Header="Description" Binding="{Binding Path=Description}" Width="350" CanUserResize="False" CanUserSort="False" CanUserReorder="False"></my:DataGridTextColumn>
                </my:DataGrid.Columns>
            </my:DataGrid>


Do you see this at runtime or design time. I put this xaml into vs2008 and had no indication of a problem.


I think u have problem with first column. your grid width is 542 and u set 182 for first column and set 350 for second column. just simple math 350+182=532

u see 532 not 542

two solution 1: add 10 to first column width

or

2: decrease 10 from grid width I hop it help

0

精彩评论

暂无评论...
验证码 换一张
取 消