views:

90

answers:

5

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

A: 
     <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>
MadSeb
A: 

Hi 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

Rev
This will create a gap on the right, not the left. Nice thinking though, but it's really juste the row header.
David Brunelle
Answer is complete !nice tip i don't know about that
Rev
A: 

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

DojoMojo
It's only going to be runtime. One thing I don't like with datagrids in WPF is that some formating only happen when data is in the grid. So if your grid is empty,you don't see it.
David Brunelle
+1  A: 

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.

David Brunelle
+1  A: 

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

svick
Didn't know that one. Gonna check that out.
David Brunelle