简体   繁体   中英

C# + Custom graphics on controls?

I was just wondering if there are ways of creating my own custom winforms controls? I've been plundering with Visual Studio 2008 now trying to do some c# apps. And the GUI end up looking terrible because of the standard winforms limitations.

And I noticed that I can add images to buttons for example, but ther's no hover effect. Or, the hover effect makes the whole button area gray. I don't want any of that, I just want to either create my own graphics for the controls or find some free (opensource perhaps) controls that already exist.

Any light on any of this, anyone? :)

You can write complete Winforms controls from scratch, doing all the painting and input processing yourself - you just create a class derived from 'Control' and get on with it.

There's a fair bit to making a first-class control which integrates nicely with the VS designer, so people tend to derive their custom control from an existing control which has most of the behaviour they want.

Here would be a good place to start: http://msdn.microsoft.com/en-us/library/6hws6h2t.aspx

First - may be more pragmatic to look at WPF, or hosting some WPF elements inside winforms (which is supported - like so ). Other than that - you can do all your own painting if you want; but it is a lot of work.

Any reason why you don't use WPF? You have much more more UI control if you went down the route.

If you must go with WinForms then there are many commercial solutions like DevExpress . If you really want you own look and feel it'll be alot of work.

Yes. You can create your own controls. It is called a User Control. Just select Add->and User Control.

WPF is a good alternative if you want your windows form to look fancy.

I'm puzzled, you are doing WinForms development, yet in comments say you have done many months of WPF development, but WPF is not good enough because it is not cross platform.

How is WinForm more cross platform, and have you seen how ugly WinForms looks under mono on a Mac as it's draw via X11.

If you want style and cross platform, go for Flex or Silverlight, as your already know WPF I'd go the Silverlight route.

It's cross platform, and has all the beauty of WPF, but at the cost of reduced functionality out of the box.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM