View previous topic :: View next topic |
Author |
Message |
tom145
Joined: 11 Nov 2007 Posts: 75
|
Posted: Sun Jan 27, 2008 3:22 pm Post subject: Two questions |
|
|
1. I want to add a row which displays totals for columns -- I want to make sure it alway appears as the last child. Is this possible to do.
2. Also when a user double clicks a row no children I want to handle the event and throw up a dialog box. I will need to locate the ActiveRow as well -- can I do this??
Thanks a lot.
Tom |
|
Back to top |
|
|
tom145
Joined: 11 Nov 2007 Posts: 75
|
Posted: Sun Jan 27, 2008 7:26 pm Post subject: Possible Bug |
|
|
Private Sub _virtualTree_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles VirtualTree.DoubleClick
Dim r As Row = Me.VirtualTree.SelectedRow
If r.NumChildren = 0 Then
Dim node As Object = r.Item
Dim msg As String = node.FieldValue("SEC TYPE")
MsgBox(msg)
End If
End Sub
I added this event handler -- sometimes when I click on a row with no children other rows which are not selected and have children collapse.
Tom |
|
Back to top |
|
|
tom145
Joined: 11 Nov 2007 Posts: 75
|
Posted: Sun Jan 27, 2008 8:42 pm Post subject: Context Menu Question |
|
|
Hello,
I was able to add a context menu. However, I want the context menu to appear only if the active row has no children and also I want to be able to determine which items will show up in the context menu based on a fieldvalue. How can I do this??
Tom |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Mon Jan 28, 2008 4:30 am Post subject: |
|
|
Quote: | I want to add a row which displays totals for columns -- I want to make sure it alway appears as the last child. Is this possible to do. |
From you previous posts I believe you are already doing Programmatic binding and handling the GetChildren event. To add additional rows you will need to add the extra objects to the e.Children collection you set in this event handler. This may mean copying the data items to a new collection and adding the total objects and then returning that collection.
Quote: | Also when a user double clicks a row no children I want to handle the event and throw up a dialog box. I will need to locate the ActiveRow as well -- can I do this?? |
You should handle the CellDoubleClick event. This is only fired when the user double clicks on a cell (ie not when they double click on a header or somewhere else). The e.Sender is CellWidget that was clicked on eg
Code: | Private Sub _virtualTree_CellDoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _virtualTree.CellDoubleClick
Dim sCellWidget As CellWidget = sender
If sCellWidget.Row.NumChildren = 0 Then
MessageBox.Show("No Children!")
End If
End Sub
|
Quote: | I was able to add a context menu. However, I want the context menu to appear only if the active row has no children and also I want to be able to determine which items will show up in the context menu based on a fieldvalue. How can I do this?? |
You need to handle the GetContextMenuStrip event eg
Code: | Private Sub _virtualTree_GetContextMenuStrip(ByVal sender As System.Object, ByVal e As GetContextMenuStripEventArgs) Handles _virtualTree.GetContextMenuStrip
If e.Row.NumChildren = 0 Then
e.ContextMenuStrip = myContextMenuStrip
End If
End Sub |
_________________ Infralution Support |
|
Back to top |
|
|
tom145
Joined: 11 Nov 2007 Posts: 75
|
Posted: Mon Jan 28, 2008 1:03 pm Post subject: Issue Resolved |
|
|
Thanks as always -- I think the double click issue is resolved.
Tom |
|
Back to top |
|
|
|