资 源 简 介
C# 设置制表位控制文本项的输出位置,将文字输出成表格的样式:
设置制表位控制文本项的输出位置
string MyText = " 姓名 高等数学 离散数学 数据结构
";
MyText = MyText + "李开斌 95 81 92
";
MyText = MyText + "汤小敏 78 84 75
";
MyText = MyText + "汤柱兰 84 76 82
";
MyText = MyText + "蒋兰坤 85 92 66
";
MyText = MyText + "黄 丽 83 91 75
";
MyText = MyText + "张中姣 75 88 82
";
FontFamily MyFontFamily = new FontFamily("宋体");
Font MyFont = new Font(MyFontFamily, 10, FontStyle.Regular, GraphicsUnit.Point);
Rectangle MyRect = new Rectangle(25, 70, 280, 110);
SolidBrush MyBrush = new SolidBrush(Color.FromArgb(255, 0, 128, 255));
StringFormat MyFormat = new StringFormat();
float[] MyTabArray = { 60, 80, 80 };
MyFormat.SetTabStops(0, MyTabArray);
e.Graphics.DrawString(MyText, MyFont, MyBrush, MyRect, MyFormat);