C# 直接访问 TableLayoutPanel 单元格
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1598620/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Direct access to TableLayoutPanel Cells
提问by captncraig
I have a TableLayoutPanel where each cell contains a single panel. I would like to be able to directly access any one of the cells by row and column and do something to the panel in it. I cannot for the life of me figure out if I can access controls within a cell. It would be great if I could do something like:
我有一个 TableLayoutPanel,其中每个单元格都包含一个面板。我希望能够按行和列直接访问任何一个单元格,并对其中的面板执行某些操作。我终生无法弄清楚我是否可以访问单元格内的控件。如果我能做这样的事情,那就太好了:
Panel p = layoutPanel.Cell(x,y).Controls[0] as Panel;
Panel p = layoutPanel.Cell(x,y).Controls[0] as Panel;
p.dosomethingCool();
p.dosomethingCool();
But I cannot seem to get that kind of access, even though it seems like something that should be quite possible.
但我似乎无法获得这种访问权限,尽管这似乎是完全可能的。
采纳答案by captncraig
I found it, it is layoutPanel.GetControlFromPosition(x,y);
我找到了,是 layoutPanel.GetControlFromPosition(x,y);