gpt4 book ai didi

c# - ToolStripDropDownButton 右对齐显示在应用程序窗口之外

转载 作者:行者123 更新时间:2023-12-04 15:17:13 34 4
gpt4 key购买 nike

在我的项目工作期间,我遇到了奇怪的问题。当我在应用程序的 ToolStrip 中正确对齐 ToolStripDropDownButton 时,它会出现在我的窗口之外。即使是全屏显示,它也会出现在我的第二台显示器上。我以为我是一个窗口担心正确对齐菜单,但似乎我错了。我使用 Windows 窗体。

这就是我要说的。这是一个生成类似问题的片段。

partial class Form2
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form2));
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.toolStripDropDownButton1 = new System.Windows.Forms.ToolStripDropDownButton();
this.itemToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStrip1.SuspendLayout();
this.SuspendLayout();
//
// toolStrip1
//
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripDropDownButton1});
this.toolStrip1.Location = new System.Drawing.Point(0, 0);
this.toolStrip1.Name = "toolStrip1";
this.toolStrip1.Size = new System.Drawing.Size(763, 25);
this.toolStrip1.TabIndex = 0;
this.toolStrip1.Text = "toolStrip1";
//
// toolStripDropDownButton1
//
this.toolStripDropDownButton1.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
this.toolStripDropDownButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
this.toolStripDropDownButton1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.itemToolStripMenuItem});
this.toolStripDropDownButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripDropDownButton1.Image")));
this.toolStripDropDownButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripDropDownButton1.Name = "toolStripDropDownButton1";
this.toolStripDropDownButton1.Size = new System.Drawing.Size(30, 22);
this.toolStripDropDownButton1.Text = "\\/";
//
// itemToolStripMenuItem
//
this.itemToolStripMenuItem.Name = "itemToolStripMenuItem";
this.itemToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.itemToolStripMenuItem.Text = "Item";
//
// Form2
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(763, 612);
this.Controls.Add(this.toolStrip1);
this.Name = "Form2";
this.Text = "Form2";
this.toolStrip1.ResumeLayout(false);
this.toolStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

public Form2()
{
InitializeComponent();
}

private System.Windows.Forms.ToolStrip toolStrip1;
private System.Windows.Forms.ToolStripDropDownButton toolStripDropDownButton1;
private System.Windows.Forms.ToolStripMenuItem itemToolStripMenuItem;
}

有没有办法强制 Windows 将此菜单绘制到左侧?

enter image description here

最佳答案

只需在按钮上设置 DropDownDirection 即可控制下拉菜单如何与按钮对齐。我认为BelowLeft是你要找的那个

toolStripDropDownButton1.DropDownDirection = ToolStripDropDownDirection.BelowLeft;

关于c# - ToolStripDropDownButton 右对齐显示在应用程序窗口之外,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36541636/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com