Results 1 to 5 of 5

Thread: [RESOLVED] DropDown TreeView

  1. #1

    Thread Starter
    Hyperactive Member stepdragon's Avatar
    Join Date
    Aug 2011
    Location
    Cincinnati
    Posts
    288

    Resolved [RESOLVED] DropDown TreeView

    I've been working on a file browser of sorts, and I've been looking for a compact way to show the filesystem. I've found a few Dropdown treeview controls available on various websites, but I can't seem to get any of them working correctly. The most promising one I have found is here: https://www.planet-source-code.com/v...3700&lngWId=10

    This control does everything I need it to functionality-wise, however there is one flaw that bothers me. When clicking on the drop down arrow the drop down flickers and disappears. This does not happen if you use the key command (Alt+Down), nor does it happen if you hold the mouse down shortly during the drop down.

    Unfortunately I cannot post the code as the author has requested that it not be reposted to other sites. However, if anyone else is able to take a look at the code and let me know if you can find out where to fix this problem?

    Additional Information: Running Windows 8.1 x64, used the Visual Studio Auto Converter to open in VS 2013 Express. <- I know this could be part of the problem, but I don't know how else to test it.



    Or if anyone knows of a working DropDown TreeView control that doesn't have this problem, I would be grateful.
    I did find another promising candidate, but it didn't pass through the BeforeSelect and AfterSelect events which I need for my project. I might have been able to add them, but it was a C# project, and I do not know enough to complete/modify it. Plus C# -> VB.Net converters don't seem to like full solutions in my experience.

    If you're wrong, you'll learn. If I'm wrong, I'll learn. Try something new and go from there. That's how we improve.

    CodeBank: VB.Net - Simple Proper Image Scaling in Correct Aspect Ratio - Star Rating Control
    Useful Links: HOW TO USE CODE TAGS

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    23,414

    Re: DropDown TreeView

    in ComboBoxTree_ComboBox.vb, you need to change 2 eventhandlers (OnDropDown and OnClick):

    Code:
    Protected Overrides Sub OnDropDown(ByVal e As System.EventArgs)
        If Not Me.DroppedDown Then
            ignore = True
            Me.DroppedDown = True
        Else
            ignore = False
        End If
    End Sub
    Code:
    Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
        If Not ignore Then
            Me.DroppedDown = False
            Me.Focus()
            Me.FindForm.Focus()
            Me.Focus()
        End If
    End Sub
    then (in that class) add a class level Boolean declaration:

    Code:
    Dim ignore As Boolean

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    23,414

    Re: DropDown TreeView

    1 more improvement:

    Code:
    Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
        If Not ignore Then
            Me.DroppedDown = False
        End If
        Me.Focus()
        Me.FindForm.Focus()
        Me.Focus()
    End Sub

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    23,414

    Re: DropDown TreeView

    2 more improvements... should work perfectly then:

    Code:
    Protected Overrides Sub OnKeyDown(ByVal e As System.Windows.Forms.KeyEventArgs)
        If (e.KeyCode = Keys.Down) AndAlso (e.Modifiers = Keys.Alt) Then
            e.Handled = True
            Me.DroppedDown = True
        ElseIf (e.KeyCode = Keys.Up) AndAlso (e.Modifiers = Keys.Alt) Then
            e.Handled = True
            Me.DroppedDown = False
        End If
    End Sub
    Code:
    Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
        If Not ignore Then
            Me.DroppedDown = False
        End If
        Me.Focus()
        Me.FindForm.Focus()
        Me.Focus()
        Me.TreeView.Focus()
    End Sub

  5. #5

    Thread Starter
    Hyperactive Member stepdragon's Avatar
    Join Date
    Aug 2011
    Location
    Cincinnati
    Posts
    288

    Re: DropDown TreeView

    Thank you!

    That worked perfectly. In my attempts to fix the problem, as it turns out, I was editing the wrong class!

    A lot of the code was duplicated in the project, so it threw me off. That was a great help, thanks.

    Apparently I try to +Rep you too often so it blocked me.

    If you're wrong, you'll learn. If I'm wrong, I'll learn. Try something new and go from there. That's how we improve.

    CodeBank: VB.Net - Simple Proper Image Scaling in Correct Aspect Ratio - Star Rating Control
    Useful Links: HOW TO USE CODE TAGS

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width