This example demonstrates how to display a check box within column headers. If the check box is checked, the corresponding column is made read-only. Uncheck the check box to allow column values to be edited.
' Developer Express Code Central Example:
' How to display a check box within column headers
'
' This example demonstrates how to display a check box within column headers. If
' the check box is checked, the corresponding column is made read-only. Uncheck
' the check box to allow column values to be edited.
'
' You can find sample updates and versions for different programming languages here:
' http://www.devexpress.com/example=E1517
Imports System
Imports System.Collections.Generic
Imports System.Configuration
Imports System.Data
Imports System.Linq
Imports System.Windows
Namespace DXGrid_ShowCheckBoxInColumnHeaders
''' <summary>
''' Interaction logic for App.xaml
''' </summary>
Partial Public Class App
Inherits Application
End Class
End Namespace
<Window x:Class="DXGrid_ShowCheckBoxInColumnHeaders.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" Title="Window1" Height="300" Width="515">
<Window.Resources>
<DataTemplate x:Key="ReadOnlyHeaderTemplate">
<dxe:CheckEdit IsChecked="{Binding Column.ReadOnly, Mode=TwoWay}" />
</DataTemplate>
</Window.Resources>
<Grid>
<dxg:GridControl x:Name="grid" AutoGenerateColumns="AddNew" ItemsSource="{Binding ListPerson}">
<dxg:GridControl.View>
<dxg:TableView AutoWidth="True" NavigationStyle="Cell"
ColumnHeaderCustomizationAreaTemplate="{StaticResource ReadOnlyHeaderTemplate}" />
</dxg:GridControl.View>
</dxg:GridControl>
</Grid>
</Window>
' Developer Express Code Central Example:
' How to display a check box within column headers
'
' This example demonstrates how to display a check box within column headers. If
' the check box is checked, the corresponding column is made read-only. Uncheck
' the check box to allow column values to be edited.
'
' You can find sample updates and versions for different programming languages here:
' http://www.devexpress.com/example=E1517
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Imaging
Imports System.Windows.Navigation
Imports System.Windows.Shapes
Imports DevExpress.Xpf.Editors
Imports DevExpress.Xpf.Grid
Namespace DXGrid_ShowCheckBoxInColumnHeaders
Partial Public Class Window1
Inherits Window
Public Sub New()
InitializeComponent()
CreateList()
DataContext = Me
End Sub
Public Property ListPerson() As List(Of Person)
Private Sub CreateList()
ListPerson = New List(Of Person)()
For i As Integer = 0 To 9
ListPerson.Add(New Person(i))
Next i
End Sub
End Class
Public Class Person
Public Sub New(ByVal i As Integer)
FirstName = "FirstName" & i
LastName = "LastName" & i
Age = i * 10
End Sub
Public Property FirstName() As String
Public Property LastName() As String
Public Property Age() As Integer
End Class
End Namespace
<Application x:Class="DXGrid_ShowCheckBoxInColumnHeaders.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="Window1.xaml">
<Application.Resources>
</Application.Resources>
</Application>
// Developer Express Code Central Example:
// How to display a check box within column headers
//
// This example demonstrates how to display a check box within column headers. If
// the check box is checked, the corresponding column is made read-only. Uncheck
// the check box to allow column values to be edited.
//
// You can find sample updates and versions for different programming languages here:
// http://www.devexpress.com/example=E1517
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using DevExpress.Xpf.Editors;
using DevExpress.Xpf.Grid;
namespace DXGrid_ShowCheckBoxInColumnHeaders {
public partial class Window1 : Window {
public Window1() {
InitializeComponent();
CreateList();
DataContext = this;
}
public List<Person> ListPerson { get; set; }
void CreateList() {
ListPerson = new List<Person>();
for (int i = 0; i < 10; i++) {
ListPerson.Add(new Person(i));
}
}
}
public class Person {
public Person(int i) {
FirstName = "FirstName" + i;
LastName = "LastName" + i;
Age = i * 10;
}
public string FirstName { get; set; }
public string LastName { get; set; }
public int Age { get; set; }
}
}