0
votes

enter image description here

Please let me know how can I remove vertical grid line for last column only.

Thanks Dee

2

2 Answers

0
votes

mark the last column width with a star

<DataGridTextColumn .... Width="*" 

that way your current last column (filler) won't appear, rather your real last column that you declared in your XAML file will stretch to the end of the visible area in the grid.

0
votes

I am assuming AutoGenerateColumn=True. If so, use the AutoGeneratingColumn event which is called when the column is generated, which means the attribute to add in xaml would be AutoGeneratingColumn=DataGrid_AutoGeneratingColumn

And the handler code will be something like this

private void DataGrid_AutoGeneratingColumn(object sender, Microsoft.Windows.Controls.DataGridAutoGeneratingColumnEventArgs e) 
    {
        if (e.PropertyName == "+") //or whatever it is
            {
                e.Cancel = false;
                e.Column.Visibility = Visibility.Collapsed;
            }
    }

Update based on comment

This is just a simple example. Try setting cell style like so

In xaml add

<Style x:Key="noborder" TargetType="{x:Type dg:DataGridCell}">
            <Setter Property="BorderThickness" Value="0"/>
</Style>

In the event handler add

e.Column.CellStyle = this.Resources["noborder"] as Style;

You can play with different style properties to get it right