We also have this requirement: disable the checkbox while allowing item selection.
We have it working mostly, but we've recently run into a situation where it breaks, because the UIElement
evaluates as Nothing. We don't really understand the UIElement, so we can't figure out why it's Nothing
but only under certain circumstances. The snippet below is our current code, which was working for awhile.
I thought I remembered getting the code off this forum, but looking at the solution above, it seems completely different.
Could you explain the difference, and provide a VB version of the code above, if that's what we should be using instead?
Thanks in advance.
'--------------------------------------------------- BEGIN CODE
For Each item As UltraListViewItem In ulvSample.Items
If item.Text = SampleID Then
'this was found in other listview, so disable its checkbox
For Each child As Infragistics.Win.UIElement In item.UIElement.ChildElements
If TypeOf child Is UltraListViewItemCheckBoxUIElement Then
Dim check As UltraListViewItemCheckBoxUIElement = TryCast(child, UltraListViewItemCheckBoxUIElement)
check.Enabled = False
End If
Next child
Else
'this was not found in other listview, so enable its checkbox
For Each child As Infragistics.Win.UIElement In item.UIElement.ChildElements
If TypeOf child Is UltraListViewItemCheckBoxUIElement Then
Dim check As UltraListViewItemCheckBoxUIElement = TryCast(child, UltraListViewItemCheckBoxUIElement)
check.Enabled = True
End If
Next child
End If
Next item
'---------------------------------------------------END CODE