PowerTools PlusPak for Windows Forms 8.0J
AutoWidth プロパティ
使用例 

ドロップダウンリストの幅を最も長いフォント名に合わせて自動的に計算するかどうかを示す値を取得または設定します。
構文
Public Property AutoWidth As Boolean
public bool AutoWidth {get; set;}

プロパティ値

自動幅調整が有効な場合はtrue、それ以外の場合はfalse。デフォルトはfalseです。
解説
ドロップダウンリストの自動幅調整が有効な場合は、SizeSystem.Drawing.Size.Widthを設定しても、AutoWidthfalseに変更されないかぎり、その設定は有効になりません。
使用例

次のサンプルコードは、GcFontPicker.DropDownSettingsプロパティ上でAutoWidthプロパティをtrueに設定して、GcFontPickerのドロップダウンリストの自動幅調整を有効にします。この例を実行するには、以下のコードをSystem.Windows.Forms.Formに追加し、ここで作成したメソッドをコンストラクターまたはフォーム上の別のメソッドから呼び出す必要があります。

private void CreateGcFontPickerWithDropDownSettings()
{
    // Create an instance of GcFontPicker control.
    GcFontPicker gcFontPicker = new GcFontPicker();

    // Initialize the Name and Location of the gcFontPicker.
    gcFontPicker.Name = "gcFontPicker";
    gcFontPicker.Location = new Point(10, 50);

    // Set some common properties on DropDownSettings.
    gcFontPicker.DropDownSettings.AutoDropDown = true;
    gcFontPicker.DropDownSettings.AutoWidth = true;
    gcFontPicker.DropDownSettings.DropDownDirection = GrapeCity.Win.Common.DropDownDirection.BelowRight;
    gcFontPicker.DropDownSettings.OpeningAnimation = GrapeCity.Win.Common.DropDownAnimation.Extend;
    gcFontPicker.DropDownSettings.ClosingAnimation = GrapeCity.Win.Common.DropDownAnimation.Extend;
    gcFontPicker.DropDownSettings.AllowResize = false;
    gcFontPicker.DropDownSettings.ShowShadow = false;

    // Set UseSystemVisualStyle to true, so that the drop-down list will be drawn by system
    // no matter what FlatStyle gcFontPicker is.
    gcFontPicker.DropDownSettings.UseSystemVisualStyle = true;

    gcFontPicker.DropDownSettings.Size = new Size(250, 300);

    // Initialize and set a shortcut menu for gcFontPicker's drop-down list.
    ContextMenuStrip myMenu = new ContextMenuStrip();
    myMenu.Items.Add("menu1");
    gcFontPicker.DropDownSettings.ContextMenuStrip = myMenu;

    // adds gcFontPicker to the form.
    this.Controls.Add(gcFontPicker);
}
Private Sub CreateGcFontPickerWithDropDownSettings()
    ' Create an instance of GcFontPicker control.
    Dim gcFontPicker As New GcFontPicker()

    ' Initialize the Name and Location of the gcFontPicker.
    gcFontPicker.Name = "gcFontPicker"
    gcFontPicker.Location = New Point(10, 50)

    ' Set some common properties on DropDownSettings.
    gcFontPicker.DropDownSettings.AutoDropDown = True
    gcFontPicker.DropDownSettings.AutoWidth = True
    gcFontPicker.DropDownSettings.DropDownDirection = Common.DropDownDirection.BelowRight
    gcFontPicker.DropDownSettings.OpeningAnimation = Common.DropDownAnimation.Extend
    gcFontPicker.DropDownSettings.ClosingAnimation = Common.DropDownAnimation.Extend
    gcFontPicker.DropDownSettings.AllowResize = False
    gcFontPicker.DropDownSettings.ShowShadow = False

    ' Set UseSystemVisualStyle to true, so that the drop-down list will be drawn by system
    ' no matter what FlatStyle gcFontPicker is.
    gcFontPicker.DropDownSettings.UseSystemVisualStyle = True

    gcFontPicker.DropDownSettings.Size = New Size(250, 300)

    ' Initialize and set a shortcut menu for gcFontPicker's drop-down list.
    Dim myMenu As New ContextMenuStrip()
    myMenu.Items.Add("menu1")
    gcFontPicker.DropDownSettings.ContextMenuStrip = myMenu

    ' adds gcFontPicker to the form.
    Me.Controls.Add(gcFontPicker)
End Sub
プラットフォーム

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

参照

FontPickerDropDownSettings クラス
FontPickerDropDownSettings メンバ
Size プロパティ
Size プロパティ

Send Feedback