using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace WindowsApplication3
{
public partial class Form1 : Form
{
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
int y = 0;
g.FillRectangle(Brushes.White , ClientRectangle);//这句就是把目前的整个窗口汇成了一个白色的底面
Rectangle rect = new Rectangle(0, y, 400, Font.Height);//这样写的却是很好了
g.DrawRectangle(Pens.Blue, rect);
g.DrawString("this is lest texts", Font, Brushes.Black, rect);////先画一个诓,然后写了一些字在上面
y += Font.Height + 20;// 这样可以控制位置
Font afont=new Font ("Arial",16, FontStyle .Bold |FontStyle .Italic);//这样就很有意思了
rect=new Rectangle (0,y,400,afont .Height*4);
StringFormat af = new StringFormat();
af.Alignment = StringAlignment.Far;
g.DrawRectangle (Pens.Yellow ,rect );
string longstr = "■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■";
longstr += "■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■";
longstr += "this is also a right texts■■■■■■■■■■■■■■■■■■■■";//就是这样的了
g.DrawString (longstr ,afont ,Brushes .BlueViolet ,rect ,af );//注意这里用了af 和 format的形式来右写
afont.Dispose();
af.Dispose();//养成良好的习惯了
base.OnPaint(e);
}
public Form1()
{
InitializeComponent();
SetStyle(ControlStyles.Opaque, true);//控件被设置为不显示背景和不透明
////结果真的是很怪异的东西了。
Bounds =new Rectangle (0,0,500,300);
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace WindowsApplication3
{
public partial class Form1 : Form
{
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
int y = 0;
g.FillRectangle(Brushes.White , ClientRectangle);//这句就是把目前的整个窗口汇成了一个白色的底面
Rectangle rect = new Rectangle(0, y, 400, Font.Height);//这样写的却是很好了
g.DrawRectangle(Pens.Blue, rect);
g.DrawString("this is lest texts", Font, Brushes.Black, rect);////先画一个诓,然后写了一些字在上面
y += Font.Height + 20;// 这样可以控制位置
Font afont=new Font ("Arial",16, FontStyle .Bold |FontStyle .Italic);//这样就很有意思了
rect=new Rectangle (0,y,400,afont .Height*4);
StringFormat af = new StringFormat();
af.Alignment = StringAlignment.Far;
g.DrawRectangle (Pens.Yellow ,rect );
string longstr = "■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■";
longstr += "■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■";
longstr += "this is also a right texts■■■■■■■■■■■■■■■■■■■■";//就是这样的了
g.DrawString (longstr ,afont ,Brushes .BlueViolet ,rect ,af );//注意这里用了af 和 format的形式来右写
afont.Dispose();
af.Dispose();//养成良好的习惯了
base.OnPaint(e);
}
public Form1()
{
InitializeComponent();
SetStyle(ControlStyles.Opaque, true);//控件被设置为不显示背景和不透明
////结果真的是很怪异的东西了。
Bounds =new Rectangle (0,0,500,300);
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}