Determine which direction a splitter is being moved

Posted on 2009-12-22
Last Modified: 2012-05-08

I am developing a touchscreen windows vb 2008 app that has a horizontal splitcontainer on the mdi parent form.

In Pane2 I have a keyboard that can be hidden/shown by pressing a button OR a user can also show/hide the keyboard by dragging the splitter up/down.
I need to either show/or hide the keyboard as they are dragging the splitter.

I also thought of just resizing panel2 and not setting the keyboards visible property but  I need a way to expand/collapse panel2 when the user presses the touchscreen button.

How do I either determine the direction the splitter is being moved OR How do I get the correct distance in order to expand/collapse panel2?

Question by:Sheritlw
    LVL 51

    Assisted Solution

    when splitter changes value, assign the value to a var and compare it

    if (oldval > splitter.value) then --> moving up
    if (oldval < splitter.value) then --> moving down
    oldval = splitter.value


    Accepted Solution

    Hi HainKurt:

    I adjusted your comment a little and now have my splitter working without having to hide/show the keyboard.
    It's not as fine tuned as I would like it to be, but it works
    In the forms SizeChanged event I set the variables
    Private Sub frmMain_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged
            miSplitValue = Me.Split1.Height / 3
            miSplitValue = miSplitValue + (miSplitValue / 2)
            Me.Split1.SplitterDistance = miSplitValue
            miButtHeight = Me.cmdKeyboard.Height + (Me.cmdKeyboard.Height / 6)
        End Sub

    In my button click event

    Private Sub cmdKeyboard_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdKeyboard.Click
            Dim p As Integer = Me.Split1.SplitterDistance
            Dim s As Integer = Me.Split1.Panel1.Height + Me.Split1.Panel2.Height

            If p = miSplitValue Then
                Me.Split1.SplitterDistance = s - miButtHeight
            ElseIf p < miSplitValue Then
                Me.Split1.SplitterDistance = s - miButtHeight
            ElseIf p > miSplitValue Then
                Me.Split1.SplitterDistance = miSplitValue
            End If

        End Sub

    Thank you for your help

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
    Article by: jpaulino
    XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String ( Literal, only instead of starting and ending with w…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now