Compartir a través de


DataGridGridLinesVisibility Enumeration

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Specifies constants that define which grid lines separating DataGrid inner cells are shown.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

Namespace:  System.Windows.Controls
Assembly:  System.Windows.Controls.Data (in System.Windows.Controls.Data.dll)

Syntax

'Declaration
<FlagsAttribute> _
Public Enumeration DataGridGridLinesVisibility
[FlagsAttribute]
public enum DataGridGridLinesVisibility
<object property="enumMemberName"/>

Members

Member name Description
None No grid lines are shown.
Horizontal Only horizontal grid lines, which separate rows, are shown.
Vertical Only vertical grid lines, which separate columns, are shown.
All Both horizontal and vertical grid lines are shown.

Remarks

This enumeration is used by the DataGrid.GridLinesVisibility property.

Examples

The following code example demonstrates how to use the DataGridGridLinesVisibility enumeration. This example is part of a larger example available in the Walkthrough: Customizing the DataGrid Control Using Properties topic.

Private Sub cbGridLines_SelectionChanged(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
    Dim cb As ComboBox = sender
    Dim cbi As ComboBoxItem = cb.SelectedItem
    If Me.dataGrid1 IsNot Nothing Then
        If cbi.Content.ToString() = "All" Then
            Me.dataGrid1.GridLinesVisibility = DataGridGridLinesVisibility.All
        ElseIf cbi.Content.ToString() = "Vertical (Default)" Then
            Me.dataGrid1.GridLinesVisibility = DataGridGridLinesVisibility.Vertical
        ElseIf cbi.Content.ToString() = "Horizontal" Then
            Me.dataGrid1.GridLinesVisibility = DataGridGridLinesVisibility.Horizontal
        Else
            Me.dataGrid1.GridLinesVisibility = DataGridGridLinesVisibility.None
        End If
    End If
End Sub
private void cbGridLines_SelectionChanged(object sender, RoutedEventArgs e)
{
    ComboBoxItem cbi = ((ComboBox)sender).SelectedItem as ComboBoxItem;
    if (this.dataGrid1 != null)
    {
        if (cbi.Content.ToString() == "All")
            this.dataGrid1.GridLinesVisibility = DataGridGridLinesVisibility.All;
        else if (cbi.Content.ToString() == "Vertical (Default)")
            this.dataGrid1.GridLinesVisibility = DataGridGridLinesVisibility.Vertical;
        else if (cbi.Content.ToString() == "Horizontal")
            this.dataGrid1.GridLinesVisibility = DataGridGridLinesVisibility.Horizontal;
        else
            this.dataGrid1.GridLinesVisibility = DataGridGridLinesVisibility.None;
    }

}

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.