它不受支持,但作为一种技巧,您可以遍历字符串中的所有字母,并在每个字母之间插入一个空格字符。您可以为它创建一个简单的函数,如下所示:
编辑 - 我在 Visual Studio 中重新做了这个并进行了测试 - 现在已经删除了错误。
private string SpacedString(string myOldString)
{
System.Text.StringBuilder newStringBuilder = new System.Text.StringBuilder("");
foreach (char c in myOldString.ToCharArray())
{
newStringBuilder.Append(c.ToString() + ' ');
}
string MyNewString = "";
if (newStringBuilder.Length > 0)
{
// remember to trim off the last inserted space
MyNewString = newStringBuilder.ToString().Substring(0, newStringBuilder.Length - 1);
}
// no else needed if the StringBuilder's length is <= 0... The resultant string would just be "", which is what it was intitialized to when declared.
return MyNewString;
}
然后您上面的代码行将被修改为:
g.DrawString(SpacedString("MyString"), new Font("Courier", 44, GraphicsUnit.Pixel), Brushes.Black, new PointF(262, 638));