1. 程式人生 > >c# 畫控制元件圓角矩形邊框

c# 畫控制元件圓角矩形邊框

private void label1_Paint(object sender, PaintEventArgs e)
        {
            Draw(e.ClipRectangle, e.Graphics, 16);
            base.OnPaint(e);
        }
private void Draw(Rectangle rectangle, Graphics g, int _radius)
        {
            Pen shadowPen = new Pen(Color.Blue);
            g.DrawPath(shadowPen, DrawRoundRect(rectangle.X, rectangle.Y, rectangle.Width - 2, rectangle.Height - 1, _radius));
        }
public static GraphicsPath DrawRoundRect(int x, int y, int width, int height, int radius)
        {
            GraphicsPath gp = new GraphicsPath();
            gp.AddArc(x, y, radius, radius, 180, 90);
            gp.AddArc(width - radius, y, radius, radius, 270, 90);
            gp.AddArc(width - radius, height - radius, radius, radius, 0, 90);
            gp.AddArc(x, height - radius, radius, radius, 90, 90);
            gp.CloseAllFigures();
            return gp;
        }

相關推薦

c# 控制元件圓角矩形邊框

private void label1_Paint(object sender, PaintEventArgs e) { Draw(e.ClipRectangle, e.Graphics, 16); base.

android 繪製控制元件圓角邊框

    在開發的過程中有時候需要把控制元件做出圓角邊框的樣子,下發介紹繪製的方法:    首先,在res下面新建一個資料夾drawable,在drawable下面新建三個xml檔案:shape_corner_down.xml、shape_corner_up.xml和sh

程式碼設定TextView、Button等控制元件圓角邊框背景顏色

int strokeWidth = 5; // 3dp 邊框寬度     int roundRadius = 15; // 8dp 圓角半徑     int strokeColor = Color.parseColor("#2E3135");//邊框顏色     int f

android shape實現控制元件圓角,背景,邊框等屬性

接下來就是shape的講解: <spanstyle="font-size:18px;"><?xmlversion="1.0"encoding="utf-8"?><shapexmlns:android="http://schemas.andro

c# DataGridView控制元件使用

DataGridView 動態新增新行:   DataGridView控制元件在實際應用中非常實用,特別需要表格顯示資料時。可以靜態繫結資料來源,這樣就自動為DataGridView控制元件新增相應的行。假如需要動態為DataGridView控制元

C# 公共控制元件之ListBox

  Winform控制元件ListBox的用法 1、如何新增listBox的值 this.listBox1.Items.Add("張曉東"); 2、如何判斷listBox集合是否新增過 //檢查新增值是否新增過 if(this.listBox1.items.Contai

C# 公共控制元件之Checkbox和CheckedListBox

Winform的開發基本都是基於控制元件事件的,也就是事件驅動型的。 多選框的放置和值的獲取有很多種,這裡介紹幾個簡單常用的方法 1、直接放置Checkbox,並獲取Checkbox的值 上圖 做法也非常簡單,就是在form中放置多個checkbox,然後迴圈遍歷,檢查其checke

C# 公共控制元件之RadioBox ,CheckBox

通常RadioBox稱為單選按鈕,CheckBox稱為多選按鈕,這兩個控制元件都是從ButtonBase類中派生,可以將其視為按鈕。   多個checkBox之間的選擇是互相獨立的,互補影響。多個RadioButton之間是互斥的,只能選擇其中一個。同一個容器下的多個RadioButton之間互

C# 公共控制元件之NotifyIcon 將視窗最小化到托盤

  1、設定窗體和notifyIcon屬性 notifyIcon  ,新增contextMenuStrip控制元件並整合到notifyIcon  的ContextMenuStrip上。 窗體 2、程式碼 using System; usi

C# 公共控制元件之maskedTextBox

IP地址框 1、新增 maskedTextBox 控制元件 2、設定屬性 3、設定MouseLeave事件 private void IPAddressOnMouseLeave(object sender, EventArgs e) { int i=0;

C# 公共控制元件之 dateTimePicker

此控制元件用起來簡單 public Form1() { InitializeComponent(); // Set the MinDate and MaxDate. dateTimePicker1.MinDate = new DateTime(1985, 6, 20);

C# 公共控制元件之ListView

private void InitListView() { // Create a new ListView control.或者 用工具箱 ListView listView1 = new ListView();

C# 公共控制元件之pictureBox

1、新增控制元件 2、分別實現是三個button功能 private void 開啟_Click(object sender, EventArgs e) { string pathname = string.Empty;

C# 公共控制元件之progressBar、 toolTip

1、窗體中加入控制元件progressBar1,  toolTip1,timer1 和三個button 2、程式碼如下: private void button1_Click(object sender, EventArgs e)//開始 { timer1.

C# 公共控制元件之TreeView

1、初始化控制元件,新增根節點,子節點 public Form1() { InitializeComponent(); InitTreeView(); } private void InitTreeView() { TreeNode parrentNode1 = tree

C# 公共控制元件之numericUpDown

1、屬性 Increment                  設定步進值,預設為1 Maximun Minimum   設定最大值最小值 DecimalPlaces

C# 公共控制元件之richTextBox

1、新增控制元件 2、新增程式碼 button1(顏色),button2(字型),button3(檢視效果) // 直接介面更改 字型和顏色 // AppendTextColorful(richTextBox1, string.Format("影象顯示操作!"), 10, Color.

C# numericUpDown控制元件的使用

namespace WindowsFormsApplication106 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object

C# 開源控制元件DockPanel 使用心得(重要)

DockPanel中提供了幾個可用的類,重要的有兩個:DockPanel和DockContent。 DockPanel是從panel繼承出來的,用於提供可浮動的dock的子視窗進行浮動和dock的場所, DockContent是從form類中繼承出來的,用於提供可浮動的視窗基類.就是說: Doc

c# OutlookBar控制元件

最近在上網的時候,發現了這個C# 下的 OutlookBar 控制元件,看了一下感覺還真不錯,特此記錄一下。 using System; using System.Drawing; using System.Windows.Forms; namespace OutLookBarDe