如何使第二个控件代替第一个控件C#

如何使第二个控件代替第一个控件C#

本文介绍了当第一个控件变为不可见时,如何使第二个控件代替第一个控件C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,



在我的项目中,我有2个组合框。根据一些条件,我必须使1stgroupbox.Visible = false

现在,我想要第2组框(它在它下面)应该取1stGroupbox的位置。

怎么样我这样做了吗?

做了一些研究,我发现如果我使用TableLayoutPanel并使用行AutoSize属性,那么我可以实现它。

只是想检查一下,有什么其他方法可以做到这一点。



我不想使用TableLayoutPanel becoz然后我需要创建一个单独的面板或usercontrol来将所有groupboxcontrols放入其中。



请建议。

谢谢。

Hello frnds,

In my project, i have 2 groupboxes. Based on some condition i have to make 1stgroupbox.Visible = false
Now, i want that the 2ndgroupbox (which was under it) should take the 1stGroupbox's place.
How can i do so?
On doing some research, i found that if i use TableLayoutPanel and play with the row AutoSize property, then i can achieve it.
Just wanted to check, are there any other ways to do this.

I dont want to use TableLayoutPanel becoz then i need to make a separate panel or usercontrol to put all the groupboxcontrols in them.

Please suggest.
thanks.

推荐答案

groupBox1.Visible = false;
groupBox2.Location = groupBox1.Location;
groupBox2.Size = groupBox1.Size;
groupBox2.Visible = true;



这篇关于当第一个控件变为不可见时,如何使第二个控件代替第一个控件C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 08:53