Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I place a panel inside a usercontrol, set its autoscroll to true and built the usercontrol.

When i place controls inside the panel at design time, it automatically shows the scrollbar if its content is larger, but i cannot scroll it, as the scrollbar doesn't respond to mouse events at design time except runtime

How can i fix this?

Thanks

What I have tried:

I created a designer and Override its GetHitTest function, but its not still working

Protected Overrides Function GetHitTest(ByVal point As System.Drawing.Point) As Boolean
         point = Control.PointToClient(point)
         Dim rect As Rectangle = Me.Host.Bounds
         Return rect.Contains(point)


     End Function
Posted
Updated 11-Mar-19 9:46am
Comments
[no name] 11-Mar-19 10:48am    
That's the "designer" and that's why it's called "design time"; it doesn't "run".

However, in the case of UWP, THAT designer can bind to a VALID data source / collection at design time and reflect it in a DataGrid, for example, while "designing"; but it still needs "data" (which you don't).

1 solution

Here is an example which shows how it must be done :
<
VB
Private HostControl As RMBaseSlider = Nothing

 Public Overrides Sub Initialize(ByVal component As System.ComponentModel.IComponent)
     MyBase.Initialize(component)

     HostControl = DirectCast(component, RMBaseSlider)
 End Sub


 Protected Overrides Function GetHitTest(point As System.Drawing.Point) As Boolean
     If HostControl IsNot Nothing Then
         Dim myPoint As Point
         If HostControl.ShowStepButtons Then
             myPoint = HostControl.ButtonLeft.PointToClient(point)
             If HostControl.ButtonLeft.ClientRectangle.Contains(myPoint) Then Return True
             myPoint = HostControl.ButtonRight.PointToClient(point)
             If HostControl.ButtonRight.ClientRectangle.Contains(myPoint) Then Return True
         End If
         myPoint = HostControl.Slider.PointToClient(point)
         If HostControl.Slider.ClientRectangle.Contains(myPoint) Then Return True
     End If

     Return MyBase.GetHitTest(point)
 End Function


This is a code-snippet out of one of my Control-Designers.
Here I have a Slider which contains 2 Buttons.
The GetHitTest delivers a TRUE to the Designer if the Mouse is located over one of these Buttons ...

I think that could help you ...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900