円を描画する

PictureBoxに円を描画する例です。

gra_ellipse

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        System.Diagnostics.PerformanceCounter pc = new System.Diagnostics.PerformanceCounter();

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            using (Graphics gra = pictureBox1.CreateGraphics())
            {
                // 円を描画
                gra.DrawEllipse(Pens.Black, 0, 0, 30, 30);

                // 中が塗りつぶされた円を描画
                gra.FillEllipse(Brushes.Blue, 60, 0, 50, 50);
            }
        }
    }
}

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

次のHTML タグと属性が使えます: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)