我试着在圆内写文本(不是以矩形居中),对齐方式必须在圆内从一行到另一行。
我已经成功地绘制了圆圈和文本。我在Stack Overflow和Google上做了研究,但没有成功地将文本放入这个圈子中。
private void Button1_Click(object sender, EventArgs e)
{
System.Drawing.Graphics graphicsObj;
graphicsObj = this.CreateGraphics();
// Create font and brush.
Font drawFont = new Font("Arial", 5);
SolidBrush drawBrush = new SolidBrush(Color.Black);
// Create point for upper-left corner of drawing.
float x = 150.0F;
float y = 50.0F;
// Set format of string.
StringFormat drawFormat = new StringFormat();
drawFormat.FormatFlags = StringFormatFlags.FitBlackBox;
graphicsObj.DrawEllipse(Pens.Red, 20, 20, 350, 350);
graphicsObj.DrawString(richTextBox1.Text.ToString(), drawFont, drawBrush, x, y, drawFormat);
}寻找建议,而不是精确的代码..
->如何建立基于矩形的文本对齐连接。预期输出,如下图所示:https://imge.to/i/miFif
完全相同,但我需要在C# Win.Form -> Wrap text inside a circular div中
发布于 2021-06-16 00:47:01
DrawString有一个带有格式选项的重载:
...
DrawString(e.Cache, text, rect,
new StringFormat() {
LineAlignment = StringAlignment.Center,
Alignment = StringAlignment.Center
});https://stackoverflow.com/questions/57626207
复制相似问题