0

如何在矩形内获取文本框 (x,y) 的位置?

    RectangleF srcRect = new Rectangle(0, 0, this.BackgroundImage.Width,
                BackgroundImage.Height);

    int nWidth = printDocument1.PrinterSettings.DefaultPageSettings.PaperSize.Width;
    int nHeight = printDocument1.PrinterSettings.DefaultPageSettings.PaperSize.Height;
    RectangleF destRect = new Rectangle(0, 0, nWidth, nHeight);

    g.DrawImage(this.BackgroundImage, destRect, srcRect, GraphicsUnit.Pixel);

     e.Graphics.DrawString(textBox15.Text, textBox15.Font, 
                           new SolidBrush(textBox15.ForeColor), 
                          /*x location base on rectangle*/, 
                          /*y location based on rectagle8*/);
4

1 回答 1

0

这是提示使用.Right.Top

e.Graphics.DrawString(textBox15.Text, textBox15.Font, new SolidBrush(textBox15.ForeColor), srcRect.Right, srcRect.Top);
于 2013-01-29T07:57:36.313 回答