Winforms:创建动态时间线控件

发布于 2024-10-09 12:22:57 字数 205 浏览 5 评论 0原文

我需要创建一个看起来像这样的 winforms 控件:

alt text 目前,我正在考虑使用图片框/面板并覆盖 onpaint 事件并自己绘制所有内容。但不知何故,这种方法似乎不太正确。

我想知道也许有更简单的方法或者更好的解决方案? 你会如何制作这样的控件?

I need to create a winforms control what looks something like this:

alt text
Currently i'm considering taking a picturebox/panel and overriding onpaint event and drawing all the stuff myself. But somehow this approach doesn't seem right.

I was wondering maybe there's an easier way out or perhaps a better solution?
How would you make a control like this?

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

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

发布评论

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

评论(3

回梦 2024-10-16 12:22:57

不,这才是正确的做法。尝试使用像 TableLayoutPanel 这样的东西不仅极其痛苦,而且还需要花费一秒钟或更长时间来绘制自己,这会导致严重的泥浆。这将需要一堆代码,但它不是硬代码。还有大量的 for 循环机会。

使用面板的 AutoScrollMinSize 获取滚动视图。使用 Graphics.TranslateTransform() 在 Paint 事件或 OnPaint 重写中传递 AutoScrollPosition。推荐后者,从Panel派生您自己的控件以保持代码分离。您可以在这里灵活地自定义外观,玩得开心。

No, that is the right way to do it. Trying to use something like a TableLayoutPanel is not only excruciatingly painful, it also sucks serious mud taking a second or more to paint itself. It will take a bunch of code, but it isn't hard code. Plenty of for loop opportunities as well.

Get the scrolling view with panel's AutoScrollMinSize. Use Graphics.TranslateTransform() passing AutoScrollPosition in the Paint event or OnPaint override. The latter is recommended, derive your own control from Panel to keep the code separate. You have lots of flexibility here to customize the appearance, have fun.

偏爱自由 2024-10-16 12:22:57

上次我做这样的事情时,我将网格作为位图,将图像加载到图片框中,然后直接在图像上绘制。使用绘制事件的问题不会持续最小化等,除非您不断重绘它。

The last time I did something like this I did the grid as a bitmap, loaded the image into a picture box, and drew directly on the image. The problem with using the paint event it's not persistent with minimizing etc unless you keep redrawing it.

送你一个梦 2024-10-16 12:22:57

覆盖文字控件或从 CompositeControl 类继承,然后使用 HTML(表)和 Javascript 呈现它(而不是绘制它)可能会更容易。

It would probably be easier to override a literal control or inherit from the CompositeControl class and then render it with HTML (tables) and Javascript as opposed to drawing it.

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