【问题标题】:How to create a winforms equivaelent control to inline-flexbox如何创建与 inline-flexbox 等效的 winforms 控件
【发布时间】:2021-07-08 10:01:53
【问题描述】:

是否可以在 .NET Winforms 中创建由 Windows 窗体上的各种 Combobox 和 Checkbox 控件驱动的 Inline-flexbox 等效项? 我不需要太复杂的东西,可能最多有 6 个带有弯曲边缘的按钮,当它们被添加到按钮内的文本并调整其大小时,它们只是内联堆叠。

this is an example you can add many of these filters and remove them by clicking the X

【问题讨论】:

  • 你看FlowLayoutPanel了吗? FlowLayoutPanel可以用来堆叠控件一个接一个,对齐由控件自己完成。
  • Thanx 现在来看看。需要能够在没有固定顺序的情况下添加或删除控件。我刚刚在堆栈溢出“在 flowlayoutpanel 中动态添加控件”上找到了这篇文章 ...stackoverflow.com/questions/16900522/…

标签: c# .net winforms button inline


【解决方案1】:

这是来自超链接并动态插入控件,因此我需要你帮助很大。我们不应该使用制表符而不是空格,因为它会导致代码出现问题吗?

for (int i = 0; i < 5; i++)
{
Button button = new Button();
button.Tag = i;
flowLayoutPanel1.Controls.Add(button);
}

【讨论】:

  • 很高兴你解决了它!如果您将代码粘贴到 IDE 中,它通常会为您处理所有文本对齐,因此它应该插入制表符。但即使不是,C# 代码对制表符或空格也不敏感,例如 YAML。
猜你喜欢
  • 2012-05-13
  • 2010-09-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-06-09
  • 1970-01-01
相关资源
最近更新 更多