How can I programmatically change the checked/unchecked value in child row cells displayed as custom cells derived from RadCheckBoxElements? Here are details of my appliation:
I have an unbound Q1 2011 RadGridView control with a single hierarchical child level in a VB.Net 2010 Winforms application . There is a 1-to-many parent-child value relationship - ie a single parent row can have multiple child row values. When the RadGridView is expanded, the multiple child rows are made up of custom cells derived from a RadCheckBoxElement. I am using a custom cell derived from RadCheckboxElement rather than a GridViewCheckView column because I want to show a text value in the cell along with the checkbox.
Selecting a child row RadCheckBoxElement-derived cell updates a value in the parent row but also needs to uncheck any other checkboxes in the same child rows. My custom RadCheckBoxElement cell takes an EventHandler as a constructor parameter so the MouseUp event of the RadCheckBoxElement can call the parent form to update the desired parent row cell. I cannot figure out how to iterate through the other child row custom cells to uncheck any checked RadCheckBoxElements.
I have created my custom cell element class derived from GridDataCellElement. Here is the partial class definition:
In the overridden CreateChildElements method I create the RadCheckboxElement and add a handler for the MouseUp event which in turn calls the passed in clickEvent. This clickEvent is passed in from the parent form in the RadGridView_CreateCell event thus:
Here is the method in the parent form that updates the desired RadGridView.ParentRow value - note that CheckBoxCellEventArgs is inherited from EventArgs with some extra fields:
I've tried finding a way to iterate through the custom cells containing RadCheckBoxElements in both the custom cell class RadCheckBoxElement_MouseUp event handler and in the parent form method passed in to the custom cell constructor as an EventHandler. Guidance would be most welcome.
Thanks,
Frank
I have an unbound Q1 2011 RadGridView control with a single hierarchical child level in a VB.Net 2010 Winforms application . There is a 1-to-many parent-child value relationship - ie a single parent row can have multiple child row values. When the RadGridView is expanded, the multiple child rows are made up of custom cells derived from a RadCheckBoxElement. I am using a custom cell derived from RadCheckboxElement rather than a GridViewCheckView column because I want to show a text value in the cell along with the checkbox.
Selecting a child row RadCheckBoxElement-derived cell updates a value in the parent row but also needs to uncheck any other checkboxes in the same child rows. My custom RadCheckBoxElement cell takes an EventHandler as a constructor parameter so the MouseUp event of the RadCheckBoxElement can call the parent form to update the desired parent row cell. I cannot figure out how to iterate through the other child row custom cells to uncheck any checked RadCheckBoxElements.
I have created my custom cell element class derived from GridDataCellElement. Here is the partial class definition:
Public
Class
CheckBoxCellElement
Inherits
GridDataCellElement
Private
chkBox
As
RadCheckBoxElement
Private
clickEvent
As
EventHandler
Public
Sub
New
(
ByVal
column
As
GridViewColumn,
ByVal
row
As
GridRowElement,
ByVal
extClickEvent
As
EventHandler)
MyBase
.
New
(column, row)
clickEvent = extClickEvent
End
Sub
In the overridden CreateChildElements method I create the RadCheckboxElement and add a handler for the MouseUp event which in turn calls the passed in clickEvent. This clickEvent is passed in from the parent form in the RadGridView_CreateCell event thus:
Private
Sub
RadGridView1_CreateCell(
ByVal
sender
As
Object
,
ByVal
e
As
Telerik.WinControls.UI.GridViewCreateCellEventArgs)
Handles
RadGridView1.CreateCell
If
Not
TypeOf
e.Column
Is
CheckBoxColumn
OrElse
Not
TypeOf
e.Row
Is
GridDataRowElement
Then
Return
e.CellElement =
New
CheckBoxCellElement(e.Column, e.Row,
New
EventHandler(
AddressOf
CheckBoxElementClicked))
Here is the method in the parent form that updates the desired RadGridView.ParentRow value - note that CheckBoxCellEventArgs is inherited from EventArgs with some extra fields:
Private
Sub
CheckBoxElementClicked(
ByVal
sender
As
Object
,
ByVal
e
As
EventArgs)
If
Not
TypeOf
sender
Is
RadCheckBoxElement
OrElse
Not
TypeOf
e
Is
CheckBoxCellEventArgs
Then
Return
Dim
evArgs
As
CheckBoxCellEventArgs =
CType
(e, CheckBoxCellEventArgs)
RadGridView1.MasterTemplate.Rows(evArgs.ParentRowIndex).Cells(_ciParentRowOptionValueColIndex).Value = evArgs.NewValue
End
Sub
I've tried finding a way to iterate through the custom cells containing RadCheckBoxElements in both the custom cell class RadCheckBoxElement_MouseUp event handler and in the parent form method passed in to the custom cell constructor as an EventHandler. Guidance would be most welcome.
Thanks,
Frank