代码之家  ›  专栏  ›  技术社区  ›  Arvo Bowen

我怎样才能得到正确的表格宽度?

  •  0
  • Arvo Bowen  · 技术社区  · 6 年前

    当使用以下代码获取窗体的大小并将另一个窗体放置在其左侧时,返回的窗体的大小似乎大于应有的大小。

    //form is the name of the second form that I'm trying to
    //position to the left of this form
    form.Left = this.Left - form.Width;
    

    回到vb6时代,我会用salewidth之类的东西来代替。在C里有类似的东西需要我用吗?还是因为阴影等原因?我怎样才能让我的第二张表格就在当前表格的旁边呢?

    当前结果

    enter image description here

    预期结果

    enter image description here

    1 回复  |  直到 6 年前
        1
  •  0
  •   Arvo Bowen    6 年前

    在尝试了几次别人的评论之后,我发现下面的内容会让我明白我在追求什么。

    form.Left = this.Left - (form.ClientRectangle.Width + SystemInformation.SizingBorderWidth);