コントロールの位置とサイズを同時に変更する
					
スポンサーリンク
コントロールの位置とサイズを同時に変更するには、SetBounds メソッドを使用します。Bounds プロパティから直接変更することもできます。
SetBounds メソッドは、第 5 引数である BoundsSpecified を指定することで、変則的な変更にも対応しています。ここでは、変更されない部分を判り易く 0 としています。
サンプルコード
以下にサンプルコードを示します。
J# 全般
    // button1 の位置を X=256, Y=128、サイズを 64 x 32 に変更する
    this.button1.SetBounds(256, 128, 64, 32);
    // Bounds プロパティを直接変更しても良い
    this.button1.set_Bounds(new Rectangle(256, 128, 64, 32));
    // すべて変更する
    this.button1.SetBounds(256, 128, 64, 32, BoundsSpecified.All);
    // 位置だけを変更する
    this.button1.SetBounds(256, 128, 0, 0, BoundsSpecified.Location);
    // サイズだけを変更する
    this.button1.SetBounds(0, 0, 64, 32, BoundsSpecified.Size);
    // Left 位置だけを変更する
    this.button1.SetBounds(256, 0, 0, 0, BoundsSpecified.X);
    // Top 位置だけを変更する
    this.button1.SetBounds(0, 128, 0, 0, BoundsSpecified.Y);
    // Width サイズだけを変更する
    this.button1.SetBounds(0, 0, 64, 0, BoundsSpecified.Width);
    // Height サイズだけを変更する
    this.button1.SetBounds(0, 0, 0, 32, BoundsSpecified.Height);
    // Left 位置と Width サイズだけを変更する (変則的な組み合わせも可能)
    this.button1.SetBounds(256, 0, 64, 0, BoundsSpecified.X | BoundsSpecified.Width);
    // Top 位置と Height サイズだけを変更する (変則的な組み合わせも可能)
    this.button1.SetBounds(0, 128, 0, 32, BoundsSpecified.Y | BoundsSpecified.Height);
関連するリファレンス
準備中です。
