Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

DataGridCheckBoxColumn Class

Represents a DataGrid column that hosts CheckBox controls in its cells.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
public class DataGridCheckBoxColumn : DataGridBoundColumn
<DataGridCheckBoxColumn .../>

The DataGridCheckBoxColumn type exposes the following members.

  NameDescription
Public methodDataGridCheckBoxColumnInitializes a new instance of the DataGridCheckBoxColumn class.
Top
  NameDescription
Public propertyActualWidthGets the current width of the column, in device-independent units (1/96th inch per unit). (Inherited from DataGridColumn.)
Public propertyBindingGets or sets the binding that associates the column with a property in the data source. (Inherited from DataGridBoundColumn.)
Public propertyCanUserReorderGets or sets a value that indicates whether the user can change the column display position by dragging the column header. (Inherited from DataGridColumn.)
Public propertyCanUserResizeGets or sets a value that indicates whether the user can adjust the column width by using the mouse. (Inherited from DataGridColumn.)
Public propertyCanUserSortGets or sets a value that indicates whether the user can sort the column by clicking the column header. (Inherited from DataGridColumn.)
Public propertyCellStyleGets or sets the style that is used to render cells in the column. (Inherited from DataGridColumn.)
Public propertyClipboardContentBindingGets or sets the binding object to use when getting or setting cell content for the clipboard. (Inherited from DataGridBoundColumn.)
Protected propertyDataGridOwnerGets the DataGrid control that contains this column. (Inherited from DataGridColumn.)
Public propertyStatic memberDefaultEditingElementStyleGets the default value of the EditingElementStyle property.
Public propertyStatic memberDefaultElementStyleGets the default value of the ElementStyle property.
Public propertyDependencyObjectTypeGets the DependencyObjectType that wraps the CLR type of this instance.  (Inherited from DependencyObject.)
Public propertyDispatcherGets the Dispatcher this DispatcherObject is associated with. (Inherited from DispatcherObject.)
Public propertyDisplayIndexGets or sets the display position of the column relative to the other columns in the DataGrid. (Inherited from DataGridColumn.)
Public propertyDragIndicatorStyleGets or sets the style object to apply to the column header during a drag operation. (Inherited from DataGridColumn.)
Public propertyEditingElementStyleGets or sets the style that is used when rendering the element that the column displays for a cell in editing mode. (Inherited from DataGridBoundColumn.)
Public propertyElementStyleGets or sets the style that is used when rendering the element that the column displays for a cell that is not in editing mode. (Inherited from DataGridBoundColumn.)
Public propertyHeaderGets or sets the content of the column header. (Inherited from DataGridColumn.)
Public propertyHeaderStringFormatGets or sets the format pattern to apply to the content of the column header. (Inherited from DataGridColumn.)
Public propertyHeaderStyleGets or sets the style that is used when rendering the column header. (Inherited from DataGridColumn.)
Public propertyHeaderTemplateGets or sets the template that defines the visual representation of the column header. (Inherited from DataGridColumn.)
Public propertyHeaderTemplateSelectorGets or sets the object that selects which template to use for the column header. (Inherited from DataGridColumn.)
Public propertyIsAutoGeneratedGets a value that indicates whether the column is auto-generated. (Inherited from DataGridColumn.)
Public propertyIsFrozenGets a value that indicates whether the column is prevented from scrolling horizontally. (Inherited from DataGridColumn.)
Public propertyIsReadOnlyGets or sets a value that indicates whether cells in the column can be edited. (Inherited from DataGridColumn.)
Public propertyIsSealedGets a value that indicates whether this instance is currently sealed (read-only). (Inherited from DependencyObject.)
Public propertyIsThreeStateGets or sets a value that indicates whether the hosted CheckBox controls enable three states or two.
Public propertyMaxWidthGets or sets the maximum width constraint of the column. (Inherited from DataGridColumn.)
Public propertyMinWidthGets or sets the minimum width constraint of the column. (Inherited from DataGridColumn.)
Public propertySortDirectionGets or sets the sort direction (ascending or descending) of the column. (Inherited from DataGridColumn.)
Public propertySortMemberPathGets or sets a property name, or a period-delimited hierarchy of property names, that indicates the member to sort by. (Inherited from DataGridColumn.)
Public propertyVisibilityGets or sets the visibility of the column. (Inherited from DataGridColumn.)
Public propertyWidthGets or sets the column width or automatic sizing mode. (Inherited from DataGridColumn.)
Top
  NameDescription
Protected methodCancelCellEditCauses the cell being edited to revert to the original, unedited value. (Inherited from DataGridColumn.)
Public methodCheckAccessDetermines whether the calling thread has access to this DispatcherObject. (Inherited from DispatcherObject.)
Public methodClearValue(DependencyProperty)Clears the local value of a property. The property to be cleared is specified by a DependencyProperty identifier. (Inherited from DependencyObject.)
Public methodClearValue(DependencyPropertyKey)Clears the local value of a read-only property. The property to be cleared is specified by a DependencyPropertyKey. (Inherited from DependencyObject.)
Public methodCoerceValueCoerces the value of the specified dependency property. This is accomplished by invoking any CoerceValueCallback function specified in property metadata for the dependency property as it exists on the calling DependencyObject. (Inherited from DependencyObject.)
Protected methodCommitCellEditPerforms any required validation before exiting cell editing mode. (Inherited from DataGridColumn.)
Public methodEqualsDetermines whether a provided DependencyObject is equivalent to the current DependencyObject. (Inherited from DependencyObject.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Protected methodGenerateEditingElementGets a CheckBox control that is bound to the column's Binding property value. (Overrides DataGridColumn.GenerateEditingElement(DataGridCell, Object).)
Protected methodGenerateElementGets a read-only CheckBox control that is bound to the column's Binding property value. (Overrides DataGridColumn.GenerateElement(DataGridCell, Object).)
Public methodGetCellContent(DataGridRow)Retrieves the Content property value for the cell at the intersection of this column and the specified row. (Inherited from DataGridColumn.)
Public methodGetCellContent(Object)Gets the Content property value for the cell at the intersection of this column and the row that represents the specified data item. (Inherited from DataGridColumn.)
Public methodGetHashCodeGets a hash code for this DependencyObject. (Inherited from DependencyObject.)
Public methodGetLocalValueEnumeratorCreates a specialized enumerator for determining which dependency properties have locally set values on this DependencyObject. (Inherited from DependencyObject.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodGetValueReturns the current effective value of a dependency property on this instance of a DependencyObject. (Inherited from DependencyObject.)
Public methodInvalidatePropertyRe-evaluates the effective value for the specified dependency property (Inherited from DependencyObject.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodNotifyPropertyChangedNotifies the DataGrid that contains this column that a column property has changed. (Inherited from DataGridColumn.)
Protected methodOnBindingChangedNotifies the DataGrid when the value of the Binding property changes. (Inherited from DataGridBoundColumn.)
Protected methodOnCoerceIsReadOnlyDetermines the value of the IsReadOnly property based on property rules from the data grid that contains this column. (Inherited from DataGridBoundColumn.)
Public methodOnCopyingCellClipboardContentRaises the CopyingCellClipboardContent event. (Inherited from DataGridColumn.)
Public methodOnPastingCellClipboardContentRaises the PastingCellClipboardContent event. (Inherited from DataGridColumn.)
Protected methodOnPropertyChangedInvoked whenever the effective value of any dependency property on this DependencyObject has been updated. The specific dependency property that changed is reported in the event data. (Inherited from DependencyObject.)
Protected methodPrepareCellForEditCalled when a cell in the column enters editing mode. (Overrides DataGridColumn.PrepareCellForEdit(FrameworkElement, RoutedEventArgs).)
Public methodReadLocalValueReturns the local value of a dependency property, if it exists. (Inherited from DependencyObject.)
Protected methodRefreshCellContentRefreshes the contents of a cell in the column in response to a column property value change. (Overrides DataGridBoundColumn.RefreshCellContent(FrameworkElement, String).)
Public methodSetCurrentValueSets the value of a dependency property without changing its value source. (Inherited from DependencyObject.)
Public methodSetValue(DependencyProperty, Object)Sets the local value of a dependency property, specified by its dependency property identifier. (Inherited from DependencyObject.)
Public methodSetValue(DependencyPropertyKey, Object)Sets the local value of a read-only dependency property, specified by the DependencyPropertyKey identifier of the dependency property. (Inherited from DependencyObject.)
Protected methodShouldSerializePropertyReturns a value that indicates whether serialization processes should serialize the value for the provided dependency property. (Inherited from DependencyObject.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodVerifyAccessEnforces that the calling thread has access to this DispatcherObject. (Inherited from DispatcherObject.)
Top
  NameDescription
Public eventCopyingCellClipboardContentOccurs after the cell clipboard content is prepared. (Inherited from DataGridColumn.)
Public eventPastingCellClipboardContentOccurs before the clipboard content is moved to the cell. (Inherited from DataGridColumn.)
Top
  NameDescription
Public fieldStatic memberIsThreeStatePropertyIdentifies the IsThreeState dependency property.
Top

Use DataGridCheckBoxColumn to display columns of Boolean data as a CheckBox. The following illustration shows an example of DataGridCheckBoxColumn.

A DataGridCheckBox column

To populate the column, bind the column to the data by using the Binding property. The Binding property is applied to the CheckBox element created in the column. The DataContext for the element in each cell is the data item for the row the cell is in. Therefore, to set up the binding you only have to set the Binding.Path. Optionally, you can specify a Binding.Converter if your data source and target are different types. For more information about data binding, see Data Binding (WPF).

You can customize the DataGridCheckBoxColumn by setting properties, such as Width, Header, IsThreeState, and IsReadOnly.

If you want to display other types of data, DataGrid provides the following column types:

Column Type

Data Display

DataGridHyperlinkColumn

Use to display URI data.

DataGridComboBoxColumn

Use to display enumeration data.

DataGridTextColumn

Use to display text.

If you want to use other controls in your DataGrid, you can create your own column types by using DataGridTemplateColumn.

The following example shows how to add a DataGridCheckBoxColumn. This example uses a database as the source and displays a column of Boolean data.

<DataGrid Name="DG1" AutoGenerateColumns="False" ItemsSource="{Binding}">
    <DataGrid.Columns>
        <DataGridCheckBoxColumn Header="Online Order?" IsThreeState="True" Binding="{Binding OnlineOrderFlag}" />
    </DataGrid.Columns>
</DataGrid>

.NET Framework

Supported in: 4.5.1, 4.5, 4

.NET Framework Client Profile

Supported in: 4

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft. All rights reserved.