当第一个控件变为不可见时,如何使第二个控件代替第一个控件C# [英] How to make a 2nd control take the place of 1st control when it becomes invisible C#

查看:75
本文介绍了当第一个控件变为不可见时,如何使第二个控件代替第一个控件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.

推荐答案

你的第一个GroupBox是不可见的,但仍然存在。您可以访问其属性:
Your first GroupBox is invisible, but does still exist. You can access its properties:
groupBox1.Visible = false;
groupBox2.Location = groupBox1.Location;
groupBox2.Size = groupBox1.Size;
groupBox2.Visible = true;


对于需要类似解决方案的人问题:

添加TableLayoutPanel,然后将控件添加到表的每一行。将表格的行和列的AutoSize属性设置为true。

为我工作。
For someone who needs the solution for similar problem:
Add TableLayoutPanel and then add your controls to each row of the table. Set the AutoSize property of table's row & column to true.
Worked for me.


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆