c# - C# 中窗体的 Control 属性中的控件顺序

标签 c# winforms user-interface controls

我对将 FlowLayoutPanel 添加到表单的 controls 属性的顺序有一个特殊的问题。这是我试过的,

我将 7 个 FlowLayoutPanel 添加到 C# 窗口应用程序中,从左到右呈垂直条状。然后我再次从左到右将流布局标记为 1、2、3、... 7。现在在表单的加载处理程序中,我编写了以下代码片段,

    foreach (FlowLayoutPanel aDaysControl in this.Controls)
    {
        MessageBox.Show(aDaysControl.Tag.ToString());
    }

我希望消息按1、2、... 7 的顺序出现。但我以相反的顺序得到它(7、6、...1)。有人可以帮我解决我犯的错误吗??

保留顺序的原因,

I am trying to make a calendar control with each row representing a day. If a month starts from Wednesday, then I need to add a empty label to the first(Monday) and the second(Tuesday) row. So the order matters a bit

最佳答案

我知道这是一个很老的问题,但是......

您可能想要使用 SetChildIndex。例如this.Controls.SetChildIndex(button1, 0);

关于c# - C# 中窗体的 Control 属性中的控件顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/280497/

相关文章:

c# - 将价格除以 3

winforms - 为什么DragDrop在VS2010下不起作用?

java - MiGLayout 大小调整在 JavaFX 中无法正常工作

css - 响应式电子邮件图像位置问题(中心)

c# - ListBox控件下奇怪的空白

.net - 使用 SpecFlow、White、Spring 和 MS Test 测试 WinForms/CompositeUI GUI

c# - 是否有一个 GetElementByTagName 来处理标签不存在的情况

c# - 如果文件不存在,Asp.net FileStream Create 会抛出错误

c# - 图层 ID 无效

c# - 计时器停止后重新启动 InActivity Monitor