Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
515
Problem with Checkboxes in WPF Datagid of Version 9.1
posted

We have a data grid control which contains a check box. The problem is that in the infragistics version 9.1, we are not able to set the

value of the checkbox to checked.The code for both data grid with check box and setting the value of checkboxes as checked to true is as under:

----------------------------------------------------------------------------------------------------------------------------

Code to set the value of the checkbox in the grid to true (this throws an exception):

----------------------------------------------------------------------------------------------------------------------------

foreach (Record rec in dgLicenseInfo.xamDataGrid1.Records)

{

((DataRecord)rec).Cells[0].Value = true;

}

----------------------------------------------------------------------------------------------------------------------------

Code for datagrid with checkbox :

----------------------------------------------------------------------------------------------------------------------------

<UserControl x:Class="Risco.RSP.AC.ACOS.UI.UControl.DataGridWithCheckbox"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

xmlns:igDP="http://infragistics.com/DataPresenter"

xmlns:Cont="clr-namespace:Risco.RSP.AC.ACOS.UI.UControl"

xmlns:sys="clr-namespace:System;assembly=mscorlib"

Height="300" Width="300" >

<Grid>

<Grid.Resources>

<Style TargetType="{x:Type igDP:CellValuePresenter}" x:Key="CheckboxField">

<Setter Property="Template">

<Setter.Value>

<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">

<Cont:CheckBoxControl Evt="GridCheckBoxChecked"

IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value, Mode=TwoWay}"/>

</ControlTemplate>

</Setter.Value>

</Setter>

</Style>

</Grid.Resources>

<igDP:XamDataGrid x:Name="xamDataGrid1" UpdateMode="OnCellChange" CellUpdated="dgdata_CellUpdated" Background="White"

BorderBrush="DarkGray" BorderThickness="1" Theme="Office2k7Blue" GroupByAreaLocation="None" AutoFit="True"

InitializeRecord="dgdata_InitializeRecord">

<igDP:XamDataGrid.FieldSettings>

<igDP:FieldSettings AllowEdit="False" CellClickAction="EnterEditModeIfAllowed" />

</igDP:XamDataGrid.FieldSettings>

<igDP:XamDataGrid.FieldLayoutSettings>

<igDP:FieldLayoutSettings DataRecordSizingMode="SizedToContentAndFixed" RecordSelectorLocation="None"

HighlightAlternateRecords="True" AutoArrangeCells="LeftToRight" AllowAddNew="False" AllowDelete="False" SelectionTypeCell="Extended" >

</igDP:FieldLayoutSettings>

</igDP:XamDataGrid.FieldLayoutSettings>

<igDP:XamDataGrid.FieldLayouts>

<igDP:FieldLayout>

<igDP:FieldLayout.Fields>

<igDP:UnboundField x:Name="CheckBoxcol" >

<igDP:UnboundField.Settings>

<igDP:FieldSettings

CellMaxWidth="17" LabelMaxWidth="17"

CellValuePresenterStyle="{StaticResource CheckboxField}" CellClickAction="SelectCell" AllowEdit="True" >

<igDP:FieldSettings.LabelPresenterStyle>

<Style TargetType="{x:Type igDP:LabelPresenter}">

<EventSetter Event="Loaded" Handler="OnNameLabelLoaded" />

</Style>

</igDP:FieldSettings.LabelPresenterStyle>

</igDP:FieldSettings>

</igDP:UnboundField.Settings>

</igDP:UnboundField>

</igDP:FieldLayout.Fields>

</igDP:FieldLayout>

</igDP:XamDataGrid.FieldLayouts>

</igDP:XamDataGrid>

</Grid>

</UserControl>