您好, 我将一个面板放在一个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中使面板在设计时可滚动
发布评论