This is a migrated thread and some comments may be shown as answers.

MDI Issue With ScrollBar

3 Answers 244 Views
Form
This is a migrated thread and some comments may be shown as answers.
Dan Harvey
Top achievements
Rank 2
Dan Harvey asked on 08 Sep 2009, 05:20 PM

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,

3 Answers, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 14 Sep 2009, 06:59 AM
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.
0
Dan Harvey
Top achievements
Rank 2
answered on 14 Sep 2009, 03:57 PM
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,
0
Deyan
Telerik team
answered on 15 Sep 2009, 08:41 AM
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.
Tags
Form
Asked by
Dan Harvey
Top achievements
Rank 2
Answers by
Deyan
Telerik team
Dan Harvey
Top achievements
Rank 2
Share this question
or