|
Infralution Support Support groups for Infralution products
|
View previous topic :: View next topic |
Author |
Message |
Raj Guest
|
Posted: Thu Jan 26, 2006 7:32 am Post subject: Capturing Events within Virtual Tree |
|
|
Hi All,
We are trying to create an advanced tree control using Virtual Tree with mulitple checkbox states for each node. To achieve this, we created a custom checkbox control that enhances a standard checkbox control.
When we run this custom control outside Virtual Tree we are able to capture the click and double click events. However, when we attempt to run the same custom control within Virtual Tree, we are unable to capture the click and double click events (and for the matter any other events). Consequently, we can't use the events to trigger critical actions in our custom control.
Specifically we developed
1. A .Net control inherited from Picturebox control which has CheckboxState property and also raises the OnCheckStateChange event when the user clicks and doubleclicks on that control
2. Another Control inherited from Virtual Tree Control which uses the above control as a prefix column
We need to capture the click and double click events (and all other events) of our custom control when we are using that control within the Virtual Tree environment.
Any suggestions that may resolve this issue would be greatly appreciated. Please note that we also submitted this issue to Infralution support and if we are able to resolve this issue we will post the resolution in this forum.
Thanks,
Raj |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Fri Jan 27, 2006 1:20 am Post subject: |
|
|
We have had a look at the code you forwarded to support and will send you back a modified copy of the solution. This illustrates how to catch events from editor controls. The editor control that is created when you add a an editor in the Virtual Tree designer is a template for the actual controls (there may be many) that are created as needed by Virtual Tree. This means that you can't simply attach an event handler to the template control. Instead Virtual Tree provides a mechanism to allow you to Initialize the editor controls when they are created and this is where you can attach handlers for the controls events.
To do this you add a handler to the CellEditor InitializeControl event. This event is called each time a control is used (the NewControl flag indicates whether the control is being used/created for the first time).
Code: | Private Sub _checkEditor_InitializeControl(ByVal sender As System.Object, ByVal e As Infralution.Controls.VirtualTree.CellEditorInitializeEventArgs) Handles _checkEditor.InitializeControl
If e.NewControl Then
Dim sControl As XtendedCheckbox = e.Control
AddHandler sControl.OnCheckStateChange, AddressOf _XtdCheckBox_OnCheckStateChange
End If
End Sub |
In this case however if you just want Virtual Tree to set the value in the cell when the CheckState changes you should simply set the CellEditor.UpdateValueEvent to be your OnCheckStateChange event. VirtualTree will then automatically hook up to this event and call your SetValueForCell method when the CheckState changes. Note that .NET programming convention is that events should not be preceeded by "On" - this is reserved for the method used to raise the event eg the OnClick method raises the Click event.
There were a few other issues with the code that you provided. One was that you had set the CellEditor.ValueProperty to be the Image property of your control. This is not the way you would normally use an editor. Instead you should probably set the CellEditor.ValueProperty to be the CheckBoxState property of your control. This allows you to supply this directly in the OnGetCellData method.
A second issue was that you had set UseCellHeight and UseCellWidth to false for the CellEditor - but the size of your control was way too big to fit in the cell. This meant that the control was not actually being displayed. Unfortunately this was masked by the fact that you had set ShowPreview to true in OnGetCellData and were returning an Image as the CellData.Value. This meant that VirtualTree displayed the image and so it looked like your control was active. _________________ Infralution Support |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|