MDI Issue With ScrollBar

4 posts, 0 answers
  1. Dan Harvey
    Dan Harvey avatar
    67 posts
    Member since:
    Jul 2008

    Posted 08 Sep 2009 Link to this post

    Hello,

    I have a master form which is the MDI parent and a child form which is the MDI child.  I use the following code to open the master form and load in a child form:

     

    Private

     

    Sub MasterForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

     

     

        Dim clientForm As New ClientForm

     

     

        With clientForm

     

            .MdiParent =

    Me

     

            .MinimizeBox =

    False    

     

            .MaximizeBox =

    False

     

     

     

            .WindowState = FormWindowState.Maximized

     

     

        End With 'clientForm    

     

     

     

     

     

        Dim document As New DocumentWindow("Document 1")

     

        clientForm.Visible =

    True

     

        clientForm.Show()

        document.AutoScroll =

    True

     

        document.Controls.Add(ClientForm)

        document.Controls(0).Location =

    New Drawing.Point(0, 0)

     

     

        Me.RadDock1.AddDocument(document)

     

     

        Me.WindowState = FormWindowState.Maximized

     

     

    End Sub

     

     

     

    I set the autoscroll property of the DocumentWindow to True, so whenever there is a field not visible a scroll bar appears, which works well.

    What I can't figure out is how do I wire up code for the mousewheel event or for the KeyDown event to scroll the scrollbar?  I was able to successfully do this creating a radform with 2 radpanels and a radvscrollbar.  But now that I am using this autoscroll, what do i reference?

    Thanks,

  2. Deyan
    Admin
    Deyan avatar
    2039 posts

    Posted 14 Sep 2009 Link to this post

    Hello Dan,

    Thanks for writing. First, I would like to apologize for the delay of my answer.

    DocumentWindow control inherits from the ScrollableControl class and thus you should be able to subscribe for its MouseWheel or KeyDown events.

    I believe that the mouse-wheel and key-down scrolling functionality should be available to you without having to handle the MouseWheel or the KeyDown event.

    However, since I am not quite sure that I correctly understand the problem that you experience, I would like to receive some more details or maybe a sample Windows Forms application which I can use to investigate the scenario and provide a proper solution.

    Thanks for your time.

    All the best,
    Deyan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Dan Harvey
    Dan Harvey avatar
    67 posts
    Member since:
    Jul 2008

    Posted 14 Sep 2009 Link to this post

    Deyan,

    Basically what I want to do is write code where I can reference the scroll bar.  For example, I have a bunch of fields on the form and when the user clicks off of a field I want to bring focus to the scrollbar so i can use the mousewheel and keydown events.

    Thanks,
  5. Deyan
    Admin
    Deyan avatar
    2039 posts

    Posted 15 Sep 2009 Link to this post

    Hello Dan,

    Thanks for getting back to me.

    Now I understand your goal. Basically, this is the behavior of a standard ContainerControl in Microsoft .NET. Our DocumentWindow class does not implement any particular functionality that might prevent you from scrolling. It inherits from the ContainerControl and thus all the functionality that you get comes actually from Microsoft .NET Framework. A possible way to go would be to manually manipulate the values of the scrollbars by using the HorizontalScrollbar, VerticalScrollbar, and AutoScrollPosition properties (all of them are defined in ScrollableControl class from which the ContainerControl class inherits). You can take a look at MSDN articles on this matter for further information:

    ScrollableControl Properties

    For example, you could use MouseWheel event of DocumentWindow control and scroll the content of the control by increasing/decreasing the Value property of the VerticalScrollbar with the amount contained in the SmallChange property (also member of VerticalScrollbar).

    I hope this is helpful. Do not hesitate to write back if you have further questions.

    All the best,
    Deyan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top