Control.ClientSize プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > Control.ClientSize プロパティの意味・解説 

Control.ClientSize プロパティ

コントロールクライアント領域の高さと幅を取得または設定します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Dim instance As Control
Dim value As Size

value = instance.ClientSize

instance.ClientSize = value
public Size ClientSize { get; set;
 }
/** @property */
public Size get_ClientSize ()

/** @property */
public void set_ClientSize (Size value)
public function get ClientSize
 () : Size

public function set ClientSize
 (value : Size)

プロパティ
コントロールクライアント領域大きさを表す Size

解説解説
使用例使用例

指定したコントロールサイズ変更して書式設定されたテキスト収容できるようにするコード例次に示します書式設定されたテキストは、コントロール割り当てられFontテキスト適用されている Text プロパティです。この例では AutoSizeControl メソッドにも、コントロールすべての端に適用する埋め込みを表す textPadding パラメータあります埋め込み均等に表示されるようにするには、テキストを ContentAlignment.MiddleCenter 値に揃えて配置します (コントロールがこれをサポートしている場合)。

Private Sub AutoSizeControl(control As
 Control, textPadding As Integer)
   ' Create a Graphics object for the Control.
   Dim g As Graphics = control.CreateGraphics()
   
   ' Get the Size needed to accommodate the formatted Text.
   Dim preferredSize As Size = g.MeasureString(
 _
     control.Text, control.Font).ToSize()
   
   ' Pad the text and resize the control.
   control.ClientSize = New Size( _
     preferredSize.Width + textPadding * 2, _
     preferredSize.Height + textPadding * 2)
   
   ' Clean up the Graphics object.
   g.Dispose()
End Sub
private void AutoSizeControl(Control control,
 int textPadding)
{
   // Create a Graphics object for the Control.
   Graphics g = control.CreateGraphics();

   // Get the Size needed to accommodate the formatted Text.
   Size preferredSize = g.MeasureString(
      control.Text, control.Font).ToSize();

   // Pad the text and resize the control.
   control.ClientSize = new Size(
      preferredSize.Width + (textPadding * 2), 
      preferredSize.Height+(textPadding * 2) );

   // Clean up the Graphics object.
   g.Dispose();
}
private:
   void AutoSizeControl( Control^ control, int
 textPadding )
   {
      
      // Create a Graphics object for the Control.
      Graphics^ g = control->CreateGraphics();
      
      // Get the Size needed to accommodate the formatted Text.
      System::Drawing::Size preferredSize = g->MeasureString( control->Text,
 control->Font ).ToSize();
      
      // Pad the text and resize the control.
      control->ClientSize = System::Drawing::Size( preferredSize.Width + (textPadding
 * 2), preferredSize.Height + (textPadding * 2) );
      
      // Clean up the Graphics object.
      delete g;
   }
private void AutoSizeControl(Control control,
 int textPadding)
{
    // Create a Graphics object for the Control.
    Graphics g = control.CreateGraphics();
    // Get the Size needed to accommodate the formatted Text.
    Size preferredSize = g.MeasureString(control.get_Text(), control.
        get_Font()).ToSize();
    // Pad the text and resize the control.
    control.set_ClientSize(new Size(preferredSize.get_Width()
 
        + textPadding * 2, preferredSize.get_Height() + textPadding * 2));
    // Clean up the Graphics object.
    g.Dispose();
} //AutoSizeControl
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Control.ClientSize プロパティ」の関連用語

Control.ClientSize プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Control.ClientSize プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS