Click here to Skip to main content
15,614,685 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all,
i want to know that is it possible to give button control any other shape says a polygon
waiting for answer
walterhevedeich 6-Aug-11 8:05am    
Windows Forms or ASP.Net?

Here is the key: to give a button really non-rectangle shape, you need to assign its Region property, naturally, to a non-rectangular Region. You can even produce non-rectangular Form!

There is a number of works (one of them is referenced by Ravi) which fail to do it and produce only a look of non-rectangular button, but the control is in fact rectangular. It's easy to find out that the implementation is louse: click in the corner (or a place of the rectangular bounding area which is not supposed to belong to a button). If Region is not set up, the button will behave as clicked even though it is not supposed to do so.

Assign Region — this is the only correct way.

Share this answer
thatraja 6-Aug-11 23:38pm    
Proposed as answer. 5!
Sergey Alexandrovich Kryukov 6-Aug-11 23:45pm    
Thank you very much, Raja.
Here you go

Pulse Button[^]
Enhanced GlassButton using GDI+[^]
For more browse here Button Controls @ Codeproject[^]

SA is right. Found this in MSDN. Control.Region Property[^]. Go ahead
Share this answer
Sergey Alexandrovich Kryukov 6-Aug-11 22:55pm    
Raja, I cannot vote before I review the code. Number of articles advise wrong way. Please look at my solution to see what I mean.
I reviewed the article referenced by Ravi and found it's wrong, and then I saw yours -- don't want to review them all. If you could look at the codes and select those using Region and confirm it, it will be a really correct answer. Right now I cannot be 100% sure.
Thank you.
thatraja 6-Aug-11 23:37pm    
You right. I suggested him custom controls. But your option is really new to me because I didn't work with those kind of things. BTW who needs non rectangular buttons :D
Sergey Alexandrovich Kryukov 6-Aug-11 23:52pm    
Fashion! But not only. When many CodeProject articles about buttons were written, they were in high demand. Also -- "liquid buttons", all together. MAC OS presentation systems encouraged people to have something like that. I can explain why I happened to make some -- a servo-driven mechanical stages. If you have a mechanical stage with 3-4 degrees of freedom where most motion if done in a plane, you naturally need a control with 8 buttons in 8 directions (in 45 degrees increment) plus one or more rotational one. Rectangular buttons would be not so elegant in this case.
thatraja 7-Aug-11 0:21am    
Agree. Normally In web I like non-rectangular buttons using images. But in windows application normal one is fine(Because I'm not interested in win forms :) & I like to work in web app).
Share this answer
Sergey Alexandrovich Kryukov 6-Aug-11 22:51pm    
Sorry, Ravi, this is not a correct article. I downloaded and review the code -- it cannot trick me into thinking it implements non-rectangular buttons. (I did not vote this time.)

How do I know that it's incorrect? Please see my solution.
You can use this
private void button1_MouseEnter(object sender, EventArgs e)
    Button sender1 = (Button)sender;
    sender1.Height += 30;
    sender1.Width += 30;
    sender1.Top -= 15;
    sender1.Left -= 15;
private void button1_MouseLeave(object sender, EventArgs e)
    Button sender1 = (Button)sender;
    sender1.Height -= 30;
    sender1.Width -= 30;
    sender1.Top += 15;
    sender1.Left += 15;
Share this answer
Sergey Alexandrovich Kryukov 6-Aug-11 22:57pm    
Totally, totally irrelevant to OP's question. And why doing this ugly position/size manipulation at all?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900