How to make form rounded rectangle or round or triangle

五迷三道 提交于 2019-12-24 16:19:37

问题


I am developing an application in C# and there is a requirement of the form of the main window in rounded rectangle or some times triangle type or round shape. so, how can I achieve this kind of features in C# 2008


回答1:


I think this is what you're looking for:

http://www.codersource.net/csharp_custom_window_forms.aspx

Also you can google for it, there are plenty examples.




回答2:


Assuming this is on Windows Forms you can check these two articles on MSDN: http://msdn.microsoft.com/en-us/library/aa289517(VS.71).aspx
http://msdn.microsoft.com/en-us/library/aa984331(VS.71).aspx

You basically have to do the following:

  • Remove the form border by setting its style to None
  • Set a background image that defines the shape of your form
  • Set the TransparencyKey of the form to the color that should be transparent



回答3:


Look at the Region property of your form. You can create a new Region, set its shape using it's various Add... methods and then assign the region to your form's region property.



来源:https://stackoverflow.com/questions/2019853/how-to-make-form-rounded-rectangle-or-round-or-triangle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!