【问题标题】:c# center label inside of imagec#图像中心标签
【发布时间】:2013-11-25 21:51:07
【问题描述】:

我的标签名为:“number1”和图片框:“picturebox2”。我想在图片框的中心设置标签。我将标签放在图片框2的中心和顶部。默认情况下 number1.Text = "99"。如果 button1 被按下 number1.Text 更改为“1”并且这会制动标签的中心位置,因为它少了 1 个字符。

我使用这段代码使标签透明:

        var pos = this.PointToScreen(number1.Location);
        pos = pictureBox2.PointToClient(pos);
        number1.Parent = pictureBox2;
        number1.Location = pos;
        number1.BackColor = Color.Transparent;

如何在标签中的数字更改时将标签放置在图像的中心?

【问题讨论】:

  • 给标签的textChanged事件赋值一个函数,并改变位置。
  • 你能给我提供代码吗...因为我是菜鸟 :) 听起来不错,但不知道该怎么做。

标签: c# image label center


【解决方案1】:

将Label的AutoSize属性改为False,将Label的Width设置为PictureBox的宽度,将TextAlign属性改为MiddleCenter。那应该可以满足您的要求。

【讨论】:

    猜你喜欢
    • 2016-09-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-29
    • 1970-01-01
    相关资源
    最近更新 更多