借鉴文章
必备类库
using System;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel;
重载控件的话,应该都有、都有。
代码示例
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Graphics g = e.Graphics;
g.Clear(this.BackColor);
SolidBrush brush = new SolidBrush(this.ForeColor);
string text = this.Text;
var size = g.MeasureString(text, this.Font);
for (int i = 1; i <= text.Length; i++)
{
if (size.Width / i < this.Width)
{
if (text.Length % i == 0)
{
for (int j = 0; j < i; j++)
{
string str = text.Substring(j * text.Length / i, text.Length / i);
var subSize = g.MeasureString(str, this.Font);
g.DrawString(str, thi