开发者

Visual Studio On/Off Control in Windows Forms

How c开发者_如何学Can I add the the sleek On/Off control to a Windows Forms application?

Or do I need to use WPF?

Example

Ignore the red highlighted area, look at the on/off controls (screenshot lifted from Visual Studio Power Productivity Tools).

Visual Studio On/Off Control in Windows Forms


In a WinForms app, you can easily create your own custom UserControl to do this (and I'm sure someone's written something like this and posted it somewhere). It's nothing more than giving a 3D recessed border to the control, and adding two labels (ON and OFF) and a disabled button and adding the code to move the button left or right on a click event. You'd want to give the control the same interface as a CheckBox (i.e. with a "Checked" property).

Incidentally, I know this control is in the style of the iPhone, which makes it supposedly "cool", but from my perspective the main achievement here is that it takes up a lot more space than a checkbox, and fundamentally ties the control to English (unless you put in the extra work to replace "ON" and "OFF" with whatever else is needed for a particular language).

This control actually makes some sense on a phone, since it's easier to manipulate with the thumb than a checkbox is. I don't think it's very valuable to have it in a Windows application (the Visual Studio designers obviously think otherwise).


Devcomponents has a commercial control that you could use.

http://www.devcomponents.com/dotnetbar/SwitchButtonControl.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜