如何在usercontrol中使面板在设计时可滚动 [英] How do I make a panel inside usercontrol scrollable at designtime

查看:75
本文介绍了如何在usercontrol中使面板在设计时可滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我将一个面板放在一个usercontrol中,将其autoscroll设置为true并构建用户控件。



当我在设计时将控件放在面板内时,如果滚动条的内容较大,它会自动显示滚动条,但是我无法滚动它,因为滚动条在设计时没有响应鼠标事件,除了运行时



我该如何解决这个问题?



谢谢



我尝试了什么:



我创建了一个设计器并覆盖了它的GetHitTest函数,但它还没有工作



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

推荐答案

这是一个显示它如何的例子必须完成:

<
Here is an example which shows how it must be done :
<
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





这是我的一个控制设计师的代码片段。

这里我有一个包含2个按钮的滑块。

如果鼠标位于其中一个按钮上,则GetHitTest会向Designer提供TRUE ...



我认为可以帮助你......



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 ...


这篇关于如何在usercontrol中使面板在设计时可滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆