我正在尝试制作一个 Label
在 C# 中,它将以固定宽度和可变高度的方式换行文本。我正在使用这段代码:
Label newMsg = new Label();
newMsg.AutoSize = true;
newMsg.MaximumSize = new Size(350, 400); //setting fixed width, max height to avoid being too high for container
newMsg.MinimumSize = new Size(350, 0); //fixed width, height doesn't matter
newMsg.Text = msg;
newMsg.Location = new Point(4, 7);
newMsg.BackColor = Color.Red; //red to see the actual size in contrast to its container
但它不起作用。我尝试做一些研究,无论文本是一个单词还是一整段,newMsg.Height
始终是 23。
有谁知道为什么?谢谢
最佳答案
就像其他人已经说过的那样,将 AutoSize
属性更改为 false,
newMsg.AutoSize = false;
关于c# - 标签尺寸不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24304524/