想格式化一个63个像素长的字符串长度,然后往里面写实际字符串,并且右对齐,如何弄

解决方案 »

  1.   

    不知道能不能帮你解决这个问题,但如下的代码是我想表达的意思:protected override void OnPaint(PaintEventArgs e)
    {
    base.OnPaint(e);
    this.m_drawList.Draw(e.Graphics);
    String text1 = "text";
    Font arialBold = new Font("Arial", 12.0F);
    Rectangle drawRect = new Rectangle(20, 20, 63, 20);//这里的大小就是像素了。
    TextRenderer.DrawText(e.Graphics, text1, arialBold, drawRect, Color.Red, TextFormatFlags.Right);
    e.Graphics.DrawRectangle(SystemPens.ControlText, drawRect);
    }