DataGridCheckBoxColumn

Posted by: juanpolessi on 7 August 2017, 5:49 pm EST

  • Posted 7 August 2017, 5:49 pm EST

    Hi,

    I have a C1DataGrid where I create the columns automatically.

    One of these columns is a DataGridCheckBoxColumn and I need to know what event I can use when the CheckBox is checked or dechecked.

    I tried to create a "DataGridCheckBoxColumn: DataGridBoundColumn" class, but I could not access the events of the CheckBox.

    Could you tell me how I can access these events?

    Thank you.
  • Replied 7 August 2017, 5:49 pm EST

    Hi,
    You can achieve the same by using custom columns as :


    <c1:C1DataGrid x:Name="dgrid" AutoGenerateColumns="False">
    <c1:C1DataGrid.Columns>
    <c1:DataGridTextColumn Binding="{Binding Name}" />
    <c1:DataGridTemplateColumn>
    <c1:DataGridTemplateColumn.CellTemplate>
    <DataTemplate>
    <CheckBox IsChecked="{Binding Path=IsChecked}" HorizontalAlignment="Center" Checked="CheckBox_Checked" Unchecked="CheckBox_Unchecked"/>
    </DataTemplate>
    </c1:DataGridTemplateColumn.CellTemplate>
    </c1:DataGridTemplateColumn>
    </c1:C1DataGrid.Columns>
    </c1:C1DataGrid>


    private void CheckBox_Checked(object sender, RoutedEventArgs e)
    {
    C1.Silverlight.DataGrid.DataGridCellPresenter parent = (e.OriginalSource as CheckBox).Parent as C1.Silverlight.DataGrid.DataGridCellPresenter;
    dgrid.CurrentRow = parent.Row;
    //write code here
    }

    private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
    {
    C1.Silverlight.DataGrid.DataGridCellPresenter parent = (e.OriginalSource as CheckBox).Parent as C1.Silverlight.DataGrid.DataGridCellPresenter;
    dgrid.CurrentRow = parent.Row;
    //write code here
    }

    Please find the attached sample for complete implementation.

    Thanks,
    Sonu
    2017/04/CheckboxColumnInDataGrid.zip
  • Marked as Answer

    Replied 7 August 2017, 5:49 pm EST

    Please find the sample application with dynamic columns attached.

    Thanks,
    Sonu
    2017/04/Grid_Mod.zip
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels