如何在usercontrol中使面板在设计时可滚动

编程入门 行业动态 更新时间:2024-10-25 20:27:13
本文介绍了如何在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中使面板在设计时可滚动

本文发布于:2023-11-03 13:20:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1555222.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:面板   如何在   usercontrol

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!