Hi,
Is there a way for TreeView to have multiple selections? But I am not
talking about its checked boxes.
I want a way similar to ListView with MultiSelect = True. So I can use
[Ctrl] or [Shift] key and click to make multiple selections. Then when I
simply click one item, all previous selections are gone.
Thanks in advance.
Li 18 15183
Hi Li,
Yes, the .Net TreeView control does not support multiple selection by
default. We normally enable checkbox for all the TreeNodes, so that we may
use CheckBox to indicate the multiple selection. However, if you really
wanted to get the true multiple selection function in TreeView, you have to
customize TreeView control. The articles below provide the extended version
of TreeView with multiple selection function:
"C# TreeView with multiple selection" http://www.codeproject.com/cs/miscctrl/treeviewms.asp
"Multi-Select TreeView" http://windowsclient.net/downloads/f...entry1273.aspx
"Multi-Select TreeView Control in C#" http://www.codeproject.com/cs/miscctrl/mwcontrols.asp
Hope this helps.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi Li,
Have you reviewed my reply to you? Does it make sense to you? If you still
need any help, please feel free to feedback, thanks.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi, Jeffrey:
Thanks a lot for the help!
I have read your response but haven't got a chance to read the articles and
try them out. I will do that after I finish my current work.
Thanks again.
Li
""Jeffrey Tan[MSFT]"" wrote:
Hi Li,
Have you reviewed my reply to you? Does it make sense to you? If you still
need any help, please feel free to feedback, thanks.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi Li,
Thank you for the confirmation.
Ok, if you need any further help, please feel free to post, thanks.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi, Jeffrey:
Now I am testing the first article: "C# TreeView with multiple selection".
The codes look ok. But I encounter a problem from TreeView.
After I click to select a node, then I click it again, it will not trigger
OnBeforeSelect or OnAfterSelect.
But if I click other nodes, i.e., not the last selected node, both of them
will be triggered.
Is TreeView designed by this way? If so, how to workaround to catch
selecting twice the node while pressing CTRL to un-select it?
By the way, I am using VB.net, not C#. But I think here is a raising event
issue.
Thanks in advance.
Li
""Jeffrey Tan[MSFT]"" wrote:
Hi Li,
Thank you for the confirmation.
Ok, if you need any further help, please feel free to post, thanks.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi Li,
Thanks for your feedback.
Yes, this behavior also occurs in build-in TreeView control and is by
design. To workaround this behavior, you may handle the TreeView.Click
event. In this event, you may use check the mouse position to determine
which node is clicked. The code below demonstrates this logic:
Private Sub TreeView1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TreeView1.Click
Dim pt As Point = Me.TreeView1.PointToClient(New
Point(Control.MousePosition.X, Control.MousePosition.Y))
Dim tn As TreeNode = Me.TreeView1.GetNodeAt(pt)
If Not (tn Is Nothing) Then
'Perform your logic based on the clicked node
End If
End Sub
Hope this helps.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Thanks!
""Jeffrey Tan[MSFT]"" wrote:
Hi Li,
Thanks for your feedback.
Yes, this behavior also occurs in build-in TreeView control and is by
design. To workaround this behavior, you may handle the TreeView.Click
event. In this event, you may use check the mouse position to determine
which node is clicked. The code below demonstrates this logic:
Private Sub TreeView1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TreeView1.Click
Dim pt As Point = Me.TreeView1.PointToClient(New
Point(Control.MousePosition.X, Control.MousePosition.Y))
Dim tn As TreeNode = Me.TreeView1.GetNodeAt(pt)
If Not (tn Is Nothing) Then
'Perform your logic based on the clicked node
End If
End Sub
Hope this helps.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi, Jeffrey:
Look like for TreeView, if I click a node (selected), I can't set its
BackColor or ForeColor in codes. It is always painted as Highlighted.
Is it by designed? If so, how can I re-paint it to normal when selecting
twice with [CTRL]?
I suspect Microsoft has made changes to TreeView so 2005 version is
different from older version (2002) the article's codes run on.
Thanks.
Li
""Jeffrey Tan[MSFT]"" wrote:
Hi Li,
Thanks for your feedback.
Yes, this behavior also occurs in build-in TreeView control and is by
design. To workaround this behavior, you may handle the TreeView.Click
event. In this event, you may use check the mouse position to determine
which node is clicked. The code below demonstrates this logic:
Private Sub TreeView1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TreeView1.Click
Dim pt As Point = Me.TreeView1.PointToClient(New
Point(Control.MousePosition.X, Control.MousePosition.Y))
Dim tn As TreeNode = Me.TreeView1.GetNodeAt(pt)
If Not (tn Is Nothing) Then
'Perform your logic based on the clicked node
End If
End Sub
Hope this helps.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi Li,
Thanks for your feedback.
Yes, .Net TreeView control encapsulates Win32 native tree view control. All
these behaviors are by design by the win32 tree view control.
To customize the hightlighted node colors, we may use custom-draw to get it
done. Fortunately, .Net2.0 has added the build-in support for custom-draw.
To use custom draw for your task, you may set TreeView.DrawMode to
OwnerDrawText and handle TreeView.DrawNode event. Then, in this event, you
may check the status of each node and paints its text and background
rectangle based on your requirement. The code snippet demonstrates this
logic:
Private tagFont As New Font("Helvetica", 8, FontStyle.Bold)
Private Sub TreeView1_DrawNode(ByVal sender As System.Object, ByVal e
As System.Windows.Forms.DrawTreeNodeEventArgs) Handles TreeView1.DrawNode
' Draw the background and node text for a selected node.
If (e.State And TreeNodeStates.Selected) <0 Then
' Draw the background of the selected node. The NodeBounds
' method makes the highlight rectangle large enough to
' include the text of a node tag, if one is present.
e.Graphics.FillRectangle(Brushes.Green, NodeBounds(e.Node))
' Retrieve the node font. If the node font has not been set,
' use the TreeView font.
Dim nodeFont As Font = e.Node.NodeFont
If nodeFont Is Nothing Then
nodeFont = CType(sender, TreeView).Font
End If
' Draw the node text.
e.Graphics.DrawString(e.Node.Text, nodeFont, Brushes.White, _
e.Bounds.Left - 2, e.Bounds.Top)
' Use the default background and node text.
Else
e.DrawDefault = True
End If
' If a node tag is present, draw its string representation
' to the right of the label text.
If (e.Node.Tag IsNot Nothing) Then
e.Graphics.DrawString(e.Node.Tag.ToString(), tagFont, _
Brushes.Yellow, e.Bounds.Right + 2, e.Bounds.Top)
End If
' If the node has focus, draw the focus rectangle large, making
' it large enough to include the text of the node tag, if present.
If (e.State And TreeNodeStates.Focused) <0 Then
Dim focusPen As New Pen(Color.Black)
Try
focusPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot
Dim focusBounds As Rectangle = NodeBounds(e.Node)
focusBounds.Size = New Size(focusBounds.Width - 1, _
focusBounds.Height - 1)
e.Graphics.DrawRectangle(focusPen, focusBounds)
Finally
focusPen.Dispose()
End Try
End If
End Sub
Private Function NodeBounds(ByVal node As TreeNode) As Rectangle
' Set the return value to the normal node bounds.
Dim bounds As Rectangle = node.Bounds
If (node.Tag IsNot Nothing) Then
' Retrieve a Graphics object from the TreeView handle
' and use it to calculate the display width of the tag.
Dim g As Graphics = Me.TreeView1.CreateGraphics()
Dim tagWidth As Integer = CInt(g.MeasureString( _
node.Tag.ToString(), tagFont).Width) + 6
' Adjust the node bounds using the calculated value.
bounds.Offset(tagWidth \ 2, 0)
bounds = Rectangle.Inflate(bounds, tagWidth \ 2, 0)
g.Dispose()
End If
Return bounds
End Function 'NodeBounds
Hope this helps.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Thanks!
""Jeffrey Tan[MSFT]"" wrote:
Hi Li,
Thanks for your feedback.
Yes, .Net TreeView control encapsulates Win32 native tree view control. All
these behaviors are by design by the win32 tree view control.
To customize the hightlighted node colors, we may use custom-draw to get it
done. Fortunately, .Net2.0 has added the build-in support for custom-draw.
To use custom draw for your task, you may set TreeView.DrawMode to
OwnerDrawText and handle TreeView.DrawNode event. Then, in this event, you
may check the status of each node and paints its text and background
rectangle based on your requirement. The code snippet demonstrates this
logic:
Private tagFont As New Font("Helvetica", 8, FontStyle.Bold)
Private Sub TreeView1_DrawNode(ByVal sender As System.Object, ByVal e
As System.Windows.Forms.DrawTreeNodeEventArgs) Handles TreeView1.DrawNode
' Draw the background and node text for a selected node.
If (e.State And TreeNodeStates.Selected) <0 Then
' Draw the background of the selected node. The NodeBounds
' method makes the highlight rectangle large enough to
' include the text of a node tag, if one is present.
e.Graphics.FillRectangle(Brushes.Green, NodeBounds(e.Node))
' Retrieve the node font. If the node font has not been set,
' use the TreeView font.
Dim nodeFont As Font = e.Node.NodeFont
If nodeFont Is Nothing Then
nodeFont = CType(sender, TreeView).Font
End If
' Draw the node text.
e.Graphics.DrawString(e.Node.Text, nodeFont, Brushes.White, _
e.Bounds.Left - 2, e.Bounds.Top)
' Use the default background and node text.
Else
e.DrawDefault = True
End If
' If a node tag is present, draw its string representation
' to the right of the label text.
If (e.Node.Tag IsNot Nothing) Then
e.Graphics.DrawString(e.Node.Tag.ToString(), tagFont, _
Brushes.Yellow, e.Bounds.Right + 2, e.Bounds.Top)
End If
' If the node has focus, draw the focus rectangle large, making
' it large enough to include the text of the node tag, if present.
If (e.State And TreeNodeStates.Focused) <0 Then
Dim focusPen As New Pen(Color.Black)
Try
focusPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot
Dim focusBounds As Rectangle = NodeBounds(e.Node)
focusBounds.Size = New Size(focusBounds.Width - 1, _
focusBounds.Height - 1)
e.Graphics.DrawRectangle(focusPen, focusBounds)
Finally
focusPen.Dispose()
End Try
End If
End Sub
Private Function NodeBounds(ByVal node As TreeNode) As Rectangle
' Set the return value to the normal node bounds.
Dim bounds As Rectangle = node.Bounds
If (node.Tag IsNot Nothing) Then
' Retrieve a Graphics object from the TreeView handle
' and use it to calculate the display width of the tag.
Dim g As Graphics = Me.TreeView1.CreateGraphics()
Dim tagWidth As Integer = CInt(g.MeasureString( _
node.Tag.ToString(), tagFont).Width) + 6
' Adjust the node bounds using the calculated value.
bounds.Offset(tagWidth \ 2, 0)
bounds = Rectangle.Inflate(bounds, tagWidth \ 2, 0)
g.Dispose()
End If
Return bounds
End Function 'NodeBounds
Hope this helps.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi, Jeffrey:
If I click to select a node, then click the node again, it will not trigger
DrawNode() event. I guess it is by design.
But with this behavior I can't draw a node to normal after selecting twice
with [CTRL]. It does trigger Click() event but Click() doesn't have
DrawNode()'s e (DrawTreeNodeEventArgs) to use to do the drawing.
Thanks.
Li
""Jeffrey Tan[MSFT]"" wrote:
Hi Li,
Thanks for your feedback.
Yes, .Net TreeView control encapsulates Win32 native tree view control. All
these behaviors are by design by the win32 tree view control.
To customize the hightlighted node colors, we may use custom-draw to get it
done. Fortunately, .Net2.0 has added the build-in support for custom-draw.
To use custom draw for your task, you may set TreeView.DrawMode to
OwnerDrawText and handle TreeView.DrawNode event. Then, in this event, you
may check the status of each node and paints its text and background
rectangle based on your requirement. The code snippet demonstrates this
logic:
Private tagFont As New Font("Helvetica", 8, FontStyle.Bold)
Private Sub TreeView1_DrawNode(ByVal sender As System.Object, ByVal e
As System.Windows.Forms.DrawTreeNodeEventArgs) Handles TreeView1.DrawNode
' Draw the background and node text for a selected node.
If (e.State And TreeNodeStates.Selected) <0 Then
' Draw the background of the selected node. The NodeBounds
' method makes the highlight rectangle large enough to
' include the text of a node tag, if one is present.
e.Graphics.FillRectangle(Brushes.Green, NodeBounds(e.Node))
' Retrieve the node font. If the node font has not been set,
' use the TreeView font.
Dim nodeFont As Font = e.Node.NodeFont
If nodeFont Is Nothing Then
nodeFont = CType(sender, TreeView).Font
End If
' Draw the node text.
e.Graphics.DrawString(e.Node.Text, nodeFont, Brushes.White, _
e.Bounds.Left - 2, e.Bounds.Top)
' Use the default background and node text.
Else
e.DrawDefault = True
End If
' If a node tag is present, draw its string representation
' to the right of the label text.
If (e.Node.Tag IsNot Nothing) Then
e.Graphics.DrawString(e.Node.Tag.ToString(), tagFont, _
Brushes.Yellow, e.Bounds.Right + 2, e.Bounds.Top)
End If
' If the node has focus, draw the focus rectangle large, making
' it large enough to include the text of the node tag, if present.
If (e.State And TreeNodeStates.Focused) <0 Then
Dim focusPen As New Pen(Color.Black)
Try
focusPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot
Dim focusBounds As Rectangle = NodeBounds(e.Node)
focusBounds.Size = New Size(focusBounds.Width - 1, _
focusBounds.Height - 1)
e.Graphics.DrawRectangle(focusPen, focusBounds)
Finally
focusPen.Dispose()
End Try
End If
End Sub
Private Function NodeBounds(ByVal node As TreeNode) As Rectangle
' Set the return value to the normal node bounds.
Dim bounds As Rectangle = node.Bounds
If (node.Tag IsNot Nothing) Then
' Retrieve a Graphics object from the TreeView handle
' and use it to calculate the display width of the tag.
Dim g As Graphics = Me.TreeView1.CreateGraphics()
Dim tagWidth As Integer = CInt(g.MeasureString( _
node.Tag.ToString(), tagFont).Width) + 6
' Adjust the node bounds using the calculated value.
bounds.Offset(tagWidth \ 2, 0)
bounds = Rectangle.Inflate(bounds, tagWidth \ 2, 0)
g.Dispose()
End If
Return bounds
End Function 'NodeBounds
Hope this helps.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi Li,
Thanks for your feedback.
You may use the logic like this:
In the event while detecting selecting twice with [CTRL], you may set a
field flag from false to true. Then call the TreeView.Invalidate() method
to redraw the entire area of TreeView control. Then the TreeView.DrawNode
event will fire again. In this event, you may check the field flag and draw
different effect based on the flag value(true or false).
If you still have anything unclear, please feel free to tell me, thanks.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi Li,
Have you reviewed my last reply to you? Does this code logic work for you?
If you still need any help or have any concern, please feel free to tell
me, thanks.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi Li,
Thanks for your feedback.
As far as I know, if we can get the TreeView working by handling it various
events, we should be able to get it working by inheriting from it and
customizing it. I can not understand your statement of "these app events
mingle with those Overrides On*** events". Can you provide a little sample
project to help me reproduce this problem? Then, I will help you to work it
out withtout duplicating code.
Thanks.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi, Jeffrey:
Here is what I did:
I created a User Control MyTreeView to inherit TreeView.
I overrided OnNodeMouseClick() to update selected nodes collection.
Inside I need to first call MyBase.OnNodeMouseClick(e).
In my application, I added MyTreeView to a form. In codes I created
MyTreeView.NodeMouseClick() event to check which nodes are selected and do
something.
Now when I click, it calls OnNodeMouseClick(), which run
MyBase.OnNodeMouseClick(e) first. It fires MyTreeView.NodeMouseClick()
immediately.
But at this time the codes after MyBase.OnNodeMouseClick(e) in
OnNodeMouseClick() hasn't been run yet. So selected nodes collection hasn't
been updated. MyTreeView.NodeMouseClick() uses the old collection so it is
not correct.
So I have to move all codes in OnNodeMouseClick() to my application's
MyTreeView.NodeMouseClick() to put them together to control the logic flow.
Is it ok if I don't call MyBase.OnNodeMouseClick(e)?
Thanks.
Li
""Jeffrey Tan[MSFT]"" wrote:
Hi Li,
Thanks for your feedback.
As far as I know, if we can get the TreeView working by handling it various
events, we should be able to get it working by inheriting from it and
customizing it. I can not understand your statement of "these app events
mingle with those Overrides On*** events". Can you provide a little sample
project to help me reproduce this problem? Then, I will help you to work it
out withtout duplicating code.
Thanks.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi Li,
Thanks for your feedback.
MyBase.OnNodeMouseClick(e) internally fires the NodeMouseClick event, so
you should call it while overriding OnNodeMouseClick() method.
Why not calling the MyBase.OnNodeMouseClick(e) after all your code logic in
OnNodeMouseClick()? That is: why not calling MyBase.OnNodeMouseClick(e) at
the end of overriding OnNodeMouseClick() instead of calling it first?
By doing this change, your code of update selected nodes collection
executed first and then MyBase.OnNodeMouseClick(e) which fires
NodeMouseClick event. So your code in NodeMouseClick event will see the
updated selected nodes collection correctly.
Hope this helps.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi, Jeffrey:
Thanks for your suggestions.
This may work in some specific scenarios. But my codes call Invalidate(),
which fire OnDrawNode(). If app uses DrawNode() event, I see a situation that
OnNodeMouseClick() --OnDrawNode() --.DrawNode() --(Back to
OnNodeMouseClick()) MyBase.OnNodeMouseClick(e) --.NodeMouseClick().
In other word, I still see these events mingle together. I may also use
other events like AfterSelect() in both app and customized TreeView.
Yes, by careful design, it may work in expected logic. But when develop
application logic, we need to check customized TreeView's events logic and
design their logic together. So in some cases it may be more straight forward
just to move the codes together to app.
Thanks.
Li
""Jeffrey Tan[MSFT]"" wrote:
Hi Li,
Thanks for your feedback.
MyBase.OnNodeMouseClick(e) internally fires the NodeMouseClick event, so
you should call it while overriding OnNodeMouseClick() method.
Why not calling the MyBase.OnNodeMouseClick(e) after all your code logic in
OnNodeMouseClick()? That is: why not calling MyBase.OnNodeMouseClick(e) at
the end of overriding OnNodeMouseClick() instead of calling it first?
By doing this change, your code of update selected nodes collection
executed first and then MyBase.OnNodeMouseClick(e) which fires
NodeMouseClick event. So your code in NodeMouseClick event will see the
updated selected nodes collection correctly.
Hope this helps.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi Li,
Thanks for your feedback.
Below are some options from me:
You should treat OnXXX like an event. We seldom use the XXX events in the
customized control, they are used for the application developer instead of
control author; as customize control author we should use OnXXX for event
processing.
Yes, I agree that application developers know nothing about the OnXXX(they
are protected methods). Application developers should use XXX events for
processing. But I did not see any problem here. As the customize control
author, the advantage of using OnXXX method is that your code can choose to
execute before and after this XXX event, although there is no guarantee
that OnXXX will execute before all XXX, YYY, ZZZ events.
I am not sure why do you say "it is not safe to use On*** events to
customize a control. You never know how other developers fire their app
events". Actually it is the OnXXX fires XXX event, not application
developers:
OnXXX(Argument e)
{
//customize control author code that executes before XXX event
if(XXX!=null)
{
XXX(e); //fires XXX event
}
//customize control author code that executes after XXX event
}
Does this make sense to you?
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: theoryboy |
last post by:
I'm trying to implement multiple selection functionality in a Tix Hlist
using a control-click. I've bound control-click to a function that uses...
|
by: jeffgeorge |
last post by:
Trying to create multiple acct reports based on the selection in a
list box. I've set the list box for multiple selections, and in the
report data...
|
by: Craig B. |
last post by:
I am relativly new to access 2000 and am having some trouble with a
report. I am not sure what I want to do is something I can do in
access. I...
|
by: Andrew |
last post by:
Hi, friends,
Is there a way to make a TreeView allow multiple selections, like in a List
control?
Thanks.
|
by: Steffen Loringer |
last post by:
Hi all,
may be an easy question: How can I allow multiple selections in a
dropdownlist?
Thanks
Steffen
|
by: Yvonne |
last post by:
We have a Contacts database which categorises our Contacts by three
categories eg Country, Language and Skills.
It has a combo box ( not bound)...
|
by: tbayse |
last post by:
Hello, I have a question about making multiple selection queries in Access. I am running windows XP and Access 2003. Up until this point I had a...
|
by: Gunnar Hurtig |
last post by:
Hi All
I am relatively new to Tkinter and am putting a wraparound to the ATNF ASAP program. In one part I present several long lists in list boxes...
|
by: Germaris |
last post by:
Hi there!
Is it possible to make multiple selections in a ComboBox ?
i.e. make n consecutive selections and store them in an array
or make n...
|
by: better678 |
last post by:
Question:
Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct?
Answer:
Java is an object-oriented...
|
by: teenabhardwaj |
last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the...
| |