This question is locked. New answers and comments are not allowed.
Hello Telerik Team, I have a checkbox column which is binded to a boolean value. I need to detect when the user checks or unchecks the checkbox column. Is there any way to detect this? I am using silverlignt 3 on VSTS 2008 SP1. If no such builtin eventhandler, is there a good workaround?
3 Answers, 1 is accepted
0
Kjell
Top achievements
Rank 1
answered on 09 Dec 2010, 12:30 AM
Does either one of these events work for you?
<telerik:GridViewCheckBoxColumn> <telerik:GridViewCheckBoxColumn.CellTemplate> <DataTemplate> <CheckBox IsChecked="false" Checked="CheckBox_Checked" Click="CheckBox_Click" /> </DataTemplate> </telerik:GridViewCheckBoxColumn.CellTemplate> </telerik:GridViewCheckBoxColumn>0
Timothy
Top achievements
Rank 1
answered on 09 Dec 2010, 01:10 AM
You can define the checkbox click event as follows,
This event first checks to see if the column type is customcolumn. You can replace this with a check for Checkbox Column, etc..
Then it does some custom things based off the current state of the cell and underlying checkbox.
This event first checks to see if the column type is customcolumn. You can replace this with a check for Checkbox Column, etc..
Then it does some custom things based off the current state of the cell and underlying checkbox.
Private Sub CheckListItemssDataGrid_CurrentCellChanged(ByVal sender As Object, ByVal e As Telerik.Windows.Controls.GridViewCurrentCellChangedEventArgs) Handles CheckListItemssDataGrid.CurrentCellChanged Dim cell As GridViewCell = CheckListItemssDataGrid.CurrentCell Dim chk As CheckBox = (cell.ChildrenOfType(Of CheckBox)()).FirstOrDefault() If TypeOf CheckListItemssDataGrid.CurrentColumn Is CustomColumn Then If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift Then If cell.Value IsNot Nothing Then cell.Value = Nothing chk.IsChecked = Nothing cell.IsEnabled = True chk.Visibility = System.Windows.Visibility.Collapsed cell.Background = New SolidColorBrush(Colors.LightGray) CheckListItemssDataGrid.CommitEdit() CheckListItemssDataGrid.SelectedItems.Clear() MessageBox.Show("Click Submit Changes When you are done disabling tasks") cell.IsCurrent = True Exit Sub ElseIf cell.Value Is Nothing Then cell.Value = False cell.Background = New SolidColorBrush(Colors.White) CheckListItemssDataGrid.CommitEdit() CheckListItemssDataGrid.SelectedItems.Clear() MessageBox.Show("Click Submit Changes When you are done modifying tasks. A page refresh is required to display previously disabled tasks properly.") Exit Sub Else End If Else If cell.Value Is Nothing Then CheckListItemssDataGrid.CancelEdit() CheckListItemssDataGrid.SelectedItems.Clear() Exit Sub End If If cell.Value = False Then If chk.IsChecked = False Then Checkbox_Click(cell) Else End If ElseIf cell.Value = True Then If chk.IsChecked = True Then cell.Background = New SolidColorBrush(Colors.White) CheckListItemssDataGrid.CommitEdit() CheckListItemssDataGrid.SelectedItems.Clear() Else End If End If End If End If End Sub0
JungTae
Top achievements
Rank 1
answered on 09 Dec 2010, 02:59 PM
Timothy, I'd love to try your code, but unfortunately, I'm coding in C# and I am unfamiliar with VB .NET..
Could you please rewrite this 1 line in c# if you can? I'll try it on my own, but chances are I'm going to get it wrong
Could you please rewrite this 1 line in c# if you can? I'll try it on my own, but chances are I'm going to get it wrong
Private Sub CheckListItemssDataGrid_CurrentCellChanged(ByVal sender As Object, ByVal e As Telerik.Windows.Controls.GridViewCurrentCellChangedEventArgs) Handles CheckListItemssDataGrid.CurrentCellChanged