using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace debug
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.ResizeRedraw, true);
AutoScroll = true;
Paint += new System.Windows.Forms.PaintEventHandler(paint);
Width = 100;
Height = 200;
}
private void paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
using (Font font = new Font("Times New Roman", 15, FontStyle.Regular, GraphicsUnit.Pixel))
{
Point p;
Point p1 = default(Point);
int i = 0;
for (i = 0; i < 50; i++)
{
if(i==0)
p = new Point(
0,0);
else
p = new Point(
0, p1.Y+15);
TextRenderer.DrawText(e.Graphics, i.ToString(), font, p, Color.Black);
p1 = new Point(p.X,p.Y);
}
AutoScrollMinSize = new Size(20, i*15);
}
e.Graphics.TranslateTransform(this.AutoScrollPosition.X, this.AutoScrollPosition.Y);
}
}
}