使用Graphics.DrawString (String, Font, Brush, Single, Single, StringFormat)将一个字符串"111111"显示为 
  1 
  1 
  1 
  1 
  1 
  1 
请问该如何设置StringFormat属性?

解决方案 »

  1.   

    这个用不到StringFormat  Graphics _Graphics = Graphics.FromHwnd(this.Handle);            string _Value = "11111111111";
                Font _SetFont = new Font("宋体", 20.5f);
                SizeF _Size =_Graphics.MeasureString(_Value,_SetFont,(int)_SetFont.Size);
                _Graphics.DrawString(_Value, _SetFont, Brushes.Red, new Rectangle(0, 0, (int)_Size.Width, (int)_Size.Height));这样看看.
      

  2.   

    楼主的想法用StringFormat实现不了,
    只能自己处理了。
      

  3.   

    只要保证StringFormat是可以折行的就行了,默认格式就是折行的。参考:protected override void OnPaint(PaintEventArgs e)
    {
    base.OnPaint(e);
    string str = "111111";
    Size size = TextRenderer.MeasureText(str, this.Font);
    Rectangle rect = new Rectangle(20, 20, size.Height, (this.Font.Height)*str.Length);
    e.Graphics.DrawString(str, this.Font, SystemBrushes.ControlText, rect);
    e.Graphics.DrawRectangle(SystemPens.ControlText, rect);
    }
      

  4.   

    如果要显示 为
    1
    1
    1
    1
    1
     字符串可以这样 "1\n1\n1\n1\n1\n"
    如果 1倒着显示 
    --
    --
    --
    --
    --
     StringFormat sf = new StringFormat();
                sf.Alignment = StringAlignment.Near;
                sf.FormatFlags = StringFormatFlags.DirectionVertical;
                sf.LineAlignment = StringAlignment.Near;
      

  5.   

    好像是 StringFormatFlags.DirectionVertical 吧~~~
      

  6.   

    把字符串定义为"1\n1\n1\n1\n1\n1"