英文:
scaling user controlls to the width of flowlayoutpanel
问题
以下是您要翻译的代码部分:
我有一个FlowLayoutPanel,它使用锚定到四个边缘,以便随着窗体大小的变化而缩放。我动态地向它添加一些用户控件。我希望用户控件在垂直方向上与FlowLayoutPanel一起缩放。我尝试了以下方法:
public void OnSizeChange(object? sender, EventArgs e)
{
foreach (UserControl cont in controls)
{
cont.Width = flowLayoutPanel1.ClientSize.Width - 10;
}
}
并将此函数添加到窗体的SizeChanged事件中,但在调整窗口大小时会出现性能问题。是否有更有效的方法可以实现这一点?
英文:
i have a flowlayoutpanel with anchors to all 4 sides so it scales with the form size. i'm adding some user controls to it dynamicly. i want the user controls to scale with the flowlayoupanel verticaly. i tried this approach:
public void OnSizeChange(object? sender, EventArgs e)
{
foreach (UserControl cont in controls)
{
cont.Width = flowLayoutPanel1.ClientSize.Width - 10;
}
}
and adding this function to form SizeChanged event but this is too laggy when resizing the window. is there a more efficient way to do it?
答案1
得分: 0
这个问题可能对你有帮助,它似乎描述了你遇到的相同问题。
基本上,解决方案似乎是你发布的代码的升级版本,我不知道性能改进是否显著。
英文:
This question might help you, it seems to describe the same problem you're having
Basically the solution seems to be a glorified version of the code you posted, I don't know if the performance improvement is significant.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论