Круг в центре формы - C#
Формулировка задачи:
Напишите приложение, которое в заголовке формы выводит ее размеры и координаты на экране, а по центру формы независимо от ее размеров изображает круг радиусом 50 пикселей. Минимальный размер формы – 70×70.
Написал вывод круга в центре, но при расширения формы круг не остается на месте ((
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Ex2
{
public partial class Form1 : Form
{
int a, b;
public Form1()
{
InitializeComponent();
a = this.ClientSize.Width/ 2 - 25;
b = this.ClientSize.Height / 2 -25;
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Pen MyPen = new Pen(Color.Black, 2);
e.Graphics.DrawEllipse(MyPen, a, b, 50, 50);
}
private void Form1_Load(object sender, EventArgs e)
{
Text = Text + a + ":";
Text = Text + b;
Text = Text + Size;
Pen MyPen = new Pen(Color.Black, 2);
}
}
}Решение задачи: «Круг в центре формы»
textual
Листинг программы
this.Invalidate();