View previous topic :: View next topic |
Author |
Message |
morgenweck
Joined: 09 Jun 2010 Posts: 21
|
Posted: Tue Jun 29, 2010 2:52 pm Post subject: Event handler |
|
|
I'm using a System.Windows.Forms.LinkLabel as a cell editor with the label of "Edit" and what I would like to happen is that when the link is clicked then the Record ID of the row would be pasted to a new form. I can't seem to find an event that will fire when the linked is clicked. Can you please point me in the right direction. Does not seem to work even with Mouseup.
Thanks |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue Jun 29, 2010 11:30 pm Post subject: |
|
|
The editor control that you define in the designer is just a template for creating the controls that Virtual Tree will actually use. For this reason events that you attach to the template control aren't fired (since it isn't the actual control being used). To attach event handlers to an editor control you need to handle the CellEditor.InitializeControl event and attach the control specific event handler inside that. _________________ Infralution Support |
|
Back to top |
|
|
morgenweck
Joined: 09 Jun 2010 Posts: 21
|
Posted: Wed Jun 30, 2010 1:03 am Post subject: |
|
|
Is there a sample somewhere? Maybe in VB?
Thanks |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Wed Jun 30, 2010 1:32 am Post subject: |
|
|
The sample projects don't do this - but the code is fairly straight forward. Below is an example:
Code: | Private Sub OnLinkClicked(ByVal sender As Object, ByVal e As LinkLabelLinkClickedEventArgs)
' handle link visit here
End Sub
Private Sub linkEditor_InitializeControl(ByVal sender As System.Object, ByVal e As CellEditorInitializeEventArgs) Handles linkEditor.InitializeControl
If e.NewControl Then
Dim sLinkLabel As LinkLabel = CType(e.Control, LinkLabel)
AddHandler sLinkLabel.LinkClicked, AddressOf OnLinkClicked
End If
End Sub
|
_________________ Infralution Support |
|
Back to top |
|
|
morgenweck
Joined: 09 Jun 2010 Posts: 21
|
Posted: Wed Jun 30, 2010 1:39 am Post subject: |
|
|
Perfect Thanks |
|
Back to top |
|
|
morgenweck
Joined: 09 Jun 2010 Posts: 21
|
Posted: Wed Jun 30, 2010 2:08 pm Post subject: |
|
|
a bit of a problem. I have added e.Control.Tag = e.CellWidget in the InitializeControl but when I drag the row to a new area that is not originally visible it seems that the referrence to the e.cellwidget is dropped. I may not be doing this the best way but I need some kind of reference to the row after the drag and drop. I'm using in the onclick
Dim sLinkLabel As LinkLabel = CType(sender, LinkLabel)
Dim cw As Infralution.Controls.VirtualTree.CellWidget = CType(sLinkLabel.Tag, Infralution.Controls.VirtualTree.CellWidget)
Dim Research As ResearchObjectInfo = CType(cw.Row.Item, ResearchObjectInfo)
But the cw.row.item comes back as nothing after the drop outside the original visible area. Is there a work around or perhaps a better approach I should be using for this?
Thanks |
|
Back to top |
|
|
morgenweck
Joined: 09 Jun 2010 Posts: 21
|
Posted: Wed Jun 30, 2010 2:43 pm Post subject: |
|
|
I think it fixed. I replaced
Dim Research As ResearchObjectInfo = CType(cw.Row.Item, ResearchObjectInfo)
with
Dim Research As ResearchObjectInfo = CType(VirtualTree.SelectedRow.Item, ResearchObjectInfo)
and everything seems to work
Thanks |
|
Back to top |
|
|
|