ToolStripDropDown.DefaultDropDownDirection Property

Definition

Gets or sets the direction in which the ToolStripDropDown is displayed relative to the ToolStrip.

public override System.Windows.Forms.ToolStripDropDownDirection DefaultDropDownDirection { get; set; }

Property Value

One of the ToolStripDropDownDirection values.

Examples

The following code example demonstrates how to assign the DefaultDropDownDirection property specified by a radio button setting.

// The following methods handle the CheckChanged event 
// for all the radio buttons. Each method calls a utility
// method to set the ToolStripDropDownDirection appropriately.

private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
    this.HandleRadioButton(sender, ToolStripDropDownDirection.AboveLeft);
}

private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
    this.HandleRadioButton(sender, ToolStripDropDownDirection.AboveRight);
}

private void radioButton3_CheckedChanged(object sender, EventArgs e)
{
    this.HandleRadioButton(sender, ToolStripDropDownDirection.BelowLeft);
}

private void radioButton4_CheckedChanged(object sender, EventArgs e)
{
    this.HandleRadioButton(sender, ToolStripDropDownDirection.BelowRight);
}

private void radioButton5_CheckedChanged(object sender, EventArgs e)
{
    this.HandleRadioButton(sender, ToolStripDropDownDirection.Default);
}

private void radioButton6_CheckedChanged(object sender, EventArgs e)
{
    this.HandleRadioButton(sender, ToolStripDropDownDirection.Left);
}

private void radioButton7_CheckedChanged(object sender, EventArgs e)
{
    this.HandleRadioButton(sender, ToolStripDropDownDirection.Right);
}

// This utility method sets the DefaultDropDownDirection property.
private void HandleRadioButton(object sender, ToolStripDropDownDirection direction)
{
    RadioButton rb = sender as RadioButton;

    if (rb != null)
    {
        if (rb.Checked)
        {
            this.dropDownDirection = direction;
            this.contextMenuStrip1.DefaultDropDownDirection = direction;
        }
    }
}

Applies to

Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9