none
C# winform圆形label怎麽做 RRS feed

  • 问题

  • 用label做了一个按钮,实际上是在label里嵌入图片,由于要做一个圆形按钮

    好像要设置label7.Region

    但是找了网上资料都找不到


    给我写信: QQ我:点击这里给我发消息

    2012年10月19日 8:41

答案

  • msdn 上的例子  查 

    Control.Region Property

    // This method will change the square button to a circular button by 
    	// creating a new circle-shaped GraphicsPath object and setting it 
    	// to the RoundButton objects region.
    	private void roundButton_Paint(object sender, 
    		System.Windows.Forms.PaintEventArgs e)
    	{
    
    		System.Drawing.Drawing2D.GraphicsPath buttonPath = 
    			new System.Drawing.Drawing2D.GraphicsPath();
    
    		// Set a new rectangle to the same size as the button's 
    		// ClientRectangle property.
    		System.Drawing.Rectangle newRectangle = roundButton.ClientRectangle;
    
    		// Decrease the size of the rectangle.
    		newRectangle.Inflate(-10, -10);
    		
    		// Draw the button's border.
    		e.Graphics.DrawEllipse(System.Drawing.Pens.Black, newRectangle);
    
    		// Increase the size of the rectangle to include the border.
    		newRectangle.Inflate( 1,  1);
    
    		// Create a circle within the new rectangle.
    		buttonPath.AddEllipse(newRectangle);
    				
    		// Set the button's Region property to the newly created 
    		// circle region.
    		roundButton.Region = new System.Drawing.Region(buttonPath);
    
    	}


    为什么的基础,是实验事实~

    2012年10月19日 9:23

全部回复

  • msdn 上的例子  查 

    Control.Region Property

    // This method will change the square button to a circular button by 
    	// creating a new circle-shaped GraphicsPath object and setting it 
    	// to the RoundButton objects region.
    	private void roundButton_Paint(object sender, 
    		System.Windows.Forms.PaintEventArgs e)
    	{
    
    		System.Drawing.Drawing2D.GraphicsPath buttonPath = 
    			new System.Drawing.Drawing2D.GraphicsPath();
    
    		// Set a new rectangle to the same size as the button's 
    		// ClientRectangle property.
    		System.Drawing.Rectangle newRectangle = roundButton.ClientRectangle;
    
    		// Decrease the size of the rectangle.
    		newRectangle.Inflate(-10, -10);
    		
    		// Draw the button's border.
    		e.Graphics.DrawEllipse(System.Drawing.Pens.Black, newRectangle);
    
    		// Increase the size of the rectangle to include the border.
    		newRectangle.Inflate( 1,  1);
    
    		// Create a circle within the new rectangle.
    		buttonPath.AddEllipse(newRectangle);
    				
    		// Set the button's Region property to the newly created 
    		// circle region.
    		roundButton.Region = new System.Drawing.Region(buttonPath);
    
    	}


    为什么的基础,是实验事实~

    2012年10月19日 9:23
  • 这个~简单,用Microsoft Expression 来做

    要不然的话,你就要用其它的插件了!

    免费的:http://www.xcgui.com/index.html

    最好的,当然,也是收费的:http://www.uipower.com/

    2012年10月20日 16:42
  • Expression是什么?


    给我写信: QQ我:点击这里给我发消息

    2012年10月21日 1:14
  • 你这个也是收费的 http://www.xcgui.com/index.html

    给我写信: QQ我:点击这里给我发消息

    2012年10月21日 1:17