C# - TabPage的颜色事件 [英] C# - TabPage Color event

查看:350
本文介绍了C# - TabPage的颜色事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C#当然不是我的强项,所以我AP preciate所有的民间大方分享他们的知识。我正与一个Windows窗体,我已经读了有关事件,并已经找到了如何修改的TabControl一些优秀的帮助,这样我就可以有一个OnDraw的事件,将添加一些色彩的标签。

C# certainly isn't my strong suit so I appreciate all the generous folk sharing their knowledge. I'm working with a Windows Form and I've read up on events and have found some excellent help on how to modify a TabControl so I can have an OnDraw event that will add some coloring to the tabs.

每个标签的颜色是基于一个连接变量的状态: 电流(绿色) 失落的(红) 陈旧(黄色)

The color of each tab is based upon the state of a connection variable: Current (green) Lost (red) Stale (yellow)

在OnDraw的事件做工精良,用于更新每个标签的颜色,但是,只有当用户选择不同的标签来查看发生。

The OnDraw event works excellent for updating the color of each tab, but that only occurs when the user selects a different tab to view.

我想发生是每个选项卡的颜色进行更新时的连接状态的变化。例如,假设标签#1为绿色,但随后的连接状态变为陈旧所以现在的标签必须为黄色,但不会获得彩色像,直到用户点击不同的标签和OnDraw的事件上被触发。

What I would like to happen is for the color of each tab to be updated whenever the connection state changes. For example, let's say Tab#1 is colored green, but then the connection state changes to stale so now the tab needs to be colored yellow but it won't get colored like that until the user clicks on a different tab and the OnDraw event is triggered.

所以我试图找出如何做到这一点。当的OnDraw事件通常触发(由用户点击不同的选项卡上)一个DrawItemEventArgs参数传递到偶数处理程序。已填充该变量与找出哪个选项卡被点击,该选项卡的边界,需要相关的数据,所以我不能确定它来自何处或如何,我可以编程方式重新创建这样的调用重彩等。选项​​卡,只要连接变量的变化。

So I'm trying to figure out how to do that. When the OnDraw event is triggered normally (by the user clicking on a different tab) a "DrawItemEventArgs" parameter is passed into the even handler. That variable is already populated with the pertinent data needed to figure out which tab was clicked on, the boundaries of that tab and etc. So I am unsure where it came from or how I can programmatically re-create such a call to re-color the tabs whenever the connection variable changes.

请让我知道如果我需要澄清的东西! 谢谢。

Please let me know if I need to clarify anything! Thank you.

推荐答案

如果你有,当你的连接状态的变化,你可以做一个事件发射了一枚

If you have an event fired when your connection state changes you could do an

InvalidateVisual()

在所有的选项卡从该事件中。

on all of your tabs from within that event.

这篇关于C# - TabPage的颜色事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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