在按钮显示隐藏状态变化时调用AdjustToolStripDimensions方法更新布局
This commit is contained in:
@@ -110,20 +110,18 @@ namespace JoyD.Windows.CS
|
|||||||
//
|
//
|
||||||
this.toolStripContainer.ContentPanel.AutoScroll = true;
|
this.toolStripContainer.ContentPanel.AutoScroll = true;
|
||||||
this.toolStripContainer.ContentPanel.Controls.Add(this.dataGridViewTempDiff);
|
this.toolStripContainer.ContentPanel.Controls.Add(this.dataGridViewTempDiff);
|
||||||
// 移除固定大小设置,让ContentPanel能根据toolStripContainer自动调整大小
|
this.toolStripContainer.ContentPanel.Size = new System.Drawing.Size(250, 400);
|
||||||
this.toolStripContainer.ContentPanel.Size = new System.Drawing.Size(0, 0);
|
|
||||||
this.toolStripContainer.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.toolStripContainer.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.toolStripContainer.Location = new System.Drawing.Point(0, 0);
|
this.toolStripContainer.Location = new System.Drawing.Point(0, 0);
|
||||||
this.toolStripContainer.Name = "toolStripContainer";
|
this.toolStripContainer.Name = "toolStripContainer";
|
||||||
// 移除固定大小设置,让toolStripContainer能根据Form自动调整大小
|
this.toolStripContainer.Size = new System.Drawing.Size(250, 450);
|
||||||
this.toolStripContainer.Size = new System.Drawing.Size(0, 0);
|
|
||||||
this.toolStripContainer.TabIndex = 0;
|
this.toolStripContainer.TabIndex = 0;
|
||||||
this.toolStripContainer.Text = "toolStripContainer";
|
this.toolStripContainer.Text = "toolStripContainer";
|
||||||
//
|
//
|
||||||
// toolStripContainer.TopToolStripPanel
|
// toolStripContainer.TopToolStripPanel
|
||||||
//
|
//
|
||||||
this.toolStripContainer.TopToolStripPanel.Controls.Add(this.toolStrip);
|
this.toolStripContainer.TopToolStripPanel.Controls.Add(this.toolStrip);
|
||||||
this.toolStripContainer.TopToolStripPanel.MinimumSize = new System.Drawing.Size(0, 100); // 大幅增加最小高度以确保有足够空间显示两行按钮
|
this.toolStripContainer.TopToolStripPanel.MinimumSize = new System.Drawing.Size(0, 25);
|
||||||
//
|
//
|
||||||
// dataGridViewTempDiff
|
// dataGridViewTempDiff
|
||||||
//
|
//
|
||||||
@@ -133,13 +131,13 @@ namespace JoyD.Windows.CS
|
|||||||
this.dataGridViewTempDiff.Name = "dataGridViewTempDiff";
|
this.dataGridViewTempDiff.Name = "dataGridViewTempDiff";
|
||||||
this.dataGridViewTempDiff.RowHeadersWidth = 25;
|
this.dataGridViewTempDiff.RowHeadersWidth = 25;
|
||||||
this.dataGridViewTempDiff.RowTemplate.Height = 27;
|
this.dataGridViewTempDiff.RowTemplate.Height = 27;
|
||||||
this.dataGridViewTempDiff.Size = new System.Drawing.Size(250, 420);
|
this.dataGridViewTempDiff.Size = new System.Drawing.Size(250, 400);
|
||||||
this.dataGridViewTempDiff.TabIndex = 0;
|
this.dataGridViewTempDiff.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// toolStrip
|
// toolStrip
|
||||||
//
|
//
|
||||||
this.toolStrip.AllowDrop = true;
|
this.toolStrip.AllowDrop = true;
|
||||||
this.toolStrip.CanOverflow = false; // 禁止溢出到下拉菜单,强制在容器内换行
|
this.toolStrip.CanOverflow = false;
|
||||||
this.toolStrip.Dock = System.Windows.Forms.DockStyle.None;
|
this.toolStrip.Dock = System.Windows.Forms.DockStyle.None;
|
||||||
this.toolStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
|
this.toolStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||||
this.toolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.toolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
@@ -155,14 +153,13 @@ namespace JoyD.Windows.CS
|
|||||||
this.btnBrushSize10,
|
this.btnBrushSize10,
|
||||||
this.btnBrushSize15,
|
this.btnBrushSize15,
|
||||||
this.btnBrushSize25});
|
this.btnBrushSize25});
|
||||||
this.toolStrip.AutoSize = true; // 启用自动大小调整以适应多行按钮
|
|
||||||
this.toolStrip.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.Flow;
|
this.toolStrip.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.Flow;
|
||||||
this.toolStrip.Location = new System.Drawing.Point(3, 0);
|
this.toolStrip.Location = new System.Drawing.Point(3, 0);
|
||||||
this.toolStrip.MaximumSize = new System.Drawing.Size(0, 100); // 增加最大高度以容纳两行按钮
|
this.toolStrip.MaximumSize = new System.Drawing.Size(0, 100);
|
||||||
this.toolStrip.MinimumSize = new System.Drawing.Size(100, 50); // 增加最小高度确保初始显示有足够空间
|
this.toolStrip.MinimumSize = new System.Drawing.Size(100, 50);
|
||||||
this.toolStrip.Name = "toolStrip";
|
this.toolStrip.Name = "toolStrip";
|
||||||
// 移除所有固定尺寸设置,完全由AutoSize控制
|
this.toolStrip.Padding = new System.Windows.Forms.Padding(5);
|
||||||
this.toolStrip.Padding = new System.Windows.Forms.Padding(5, 5, 5, 5); // 增加内边距确保按钮有足够空间排列
|
this.toolStrip.Size = new System.Drawing.Size(247, 50);
|
||||||
this.toolStrip.TabIndex = 3;
|
this.toolStrip.TabIndex = 3;
|
||||||
this.toolStrip.Text = "工具条";
|
this.toolStrip.Text = "工具条";
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -551,6 +551,11 @@ namespace JoyD.Windows.CS
|
|||||||
{
|
{
|
||||||
Console.WriteLine("更新画笔大小按钮可见性失败: " + ex.Message);
|
Console.WriteLine("更新画笔大小按钮可见性失败: " + ex.Message);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// 按钮可见性变化后,重新调整toolStrip尺寸
|
||||||
|
AdjustToolStripDimensions();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DataGridViewTempDiff_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
|
private void DataGridViewTempDiff_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
|
||||||
@@ -762,6 +767,11 @@ namespace JoyD.Windows.CS
|
|||||||
{
|
{
|
||||||
Console.WriteLine("更新按钮可见性失败: " + ex.Message);
|
Console.WriteLine("更新按钮可见性失败: " + ex.Message);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// 按钮可见性变化后,重新调整toolStrip尺寸
|
||||||
|
AdjustToolStripDimensions();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user