如何将flowlayoutpanel中的所有按钮都放到数组中?

How to put all buttons in flowlayoutpanel to array?

我在 vb.net 到 select 表单中的所有按钮中有一个代码 flowlayoutpanel,但它 returns 为零。

我认为问题出在流程布局面板上。

Dim alphabetButtons() As Button
alphabetButtons = Me.Controls.OfType(Of Button).Except(New Button() {Button1}).ToArray

你能告诉我我做错了什么吗?

I have a code in vb.net to select all buttons in form within flowlayoutpanel, but it returns zero. ... Can you tell me what am I doing wrong?

是的。你告诉 Form 到 return 类型按钮的所有控件:

Dim alphabetButtons() As Button
alphabetButtons = Me.Controls.OfType(Of Button).Except(New Button() {Button1}).ToArray

这个问题你需要问FlowLayoutPanel

Me更改为您的FlowLayoutPanel的名称,例如下面"fixed"代码中的FlowLayoutPanel1

Dim alphabetButtons() As Button
alphabetButtons = FlowLayoutPanel1.Controls.OfType(Of Button).Except(New Button() {Button1}).ToArray

Controls() 集合仅 return 控件直接 包含在该容器中。每个容器都有自己的子控件集合...