进度条点击(紧凑框架)

发布于 2024-07-24 23:57:54 字数 110 浏览 2 评论 0原文

我正在使用进度条来显示电池状态。 如果用户单击进度条,我想显示一个包含详细信息的弹出窗口。

除了需要检查点击坐标是否在进度条范围内的解决方案之外,有人找到了其他解决方案或解决方法吗?

I'm using a progress bar to display the battery status. If the user clicks on the progress bar i want to display a popup with details.

Excluding the solution that requires checking if the click coordonates is in the bounds of the progress bar has anyone found another solution or a workaround to this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

心是晴朗的。 2024-07-31 23:57:55

好的,执行自定义控件的一种更简单的方法是从 UserControl 开始,在其上放置一个 ProgressBar 并将其停靠以使其填充 UserControl,然后将 ProgressBar 公开为 UserControl 的公共属性,以便您的代码说

myProgressBar1.ProgressBar.Max = 100

而不是

progressBar1.Max = 100

然后只需使用用户控件的 Click 事件来显示详细信息(我认为您可能必须禁用内部 ProgressBar 才能使单击正常工作,但这不应影响进度栏的外观)。

这样你的用户控件看起来就像一个常规的进度条(因此,就像屁股一样)。 :)

OK, an easier way to do the custom control is to just start with a UserControl, drop a ProgressBar on it and dock it so that it fills the UserControl, then expose the ProgressBar as a public property of the UserControl, so that your code would say

myProgressBar1.ProgressBar.Max = 100

instead of

progressBar1.Max = 100

Then just use the Click event of the usercontrol to show the details (I think you might have to disable the inner ProgressBar for the click to work, but that shouldn't affect the appearance of the progress bar).

This way your user control looks exactly like a regular progress bar (and, hence, like ass). :)

撩发小公举 2024-07-31 23:57:55

此外,仅以用户习惯的方式使用控件通常被认为是良好的形式。 进度条仅用于(并且传统上使用)显示信息。 这就是为什么他们删除了 Compact Framework 中的所有交互事件。

我认为更好的方法是保持进度条不变,并在进度条上方或旁边添加一个“详细信息”链接标签。

Also, it's generally considered good form to only use controls in the way that users are accustomed to. Progress bars are meant (and traditionally used) only to display information. This is why they removed all the interaction events in Compact Framework.

I think a better approach would be to leave the progress bar as it is, and add a "Details" LinkLabel above or next to the bar.

心的憧憬 2024-07-31 23:57:55

我一直只是编写自己的自定义 ProgressBar 用户控件。 写起来大概需要 5 分钟,而且内置的进度条控件无论如何看起来都很糟糕。

我认为可以使用反射来实现此目的,但编写自己的控件会更容易。

更新:我只是尝试将 ProgressBar 转换为控件(它确实有 Click 事件),然后在代码中分配事件处理程序,但这似乎不起作用。

I've always just written my own custom ProgressBar usercontrol. It takes maybe 5 minutes to write, and the built-in progress bar control looks like ass anyway.

I think it might be possible to use Reflection for this, but it would easier to just write your own control.

Update: I just tried casting the ProgressBar as a Control (which does have a Click event) and then assigning an event handler in code, but this does not appear to work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文