c#中的show \hide控件 [英] show\hide controls in c#

查看:233
本文介绍了c#中的show \hide控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#windows应用程序中有一个表单。在这种形式我有一个文本框和按钮。当我点击这个按钮时,我必须显示该文本框,否则我必须隐藏它。



我通过使用属性可见来完成此操作。但是这个文本框的空间仍然可用。我也想要隐藏那个空间。

I have a form in C# windows application. In this form I have a textbox and button. When I clicked this button I have to show that textbox otherwise I have to hide it.

I have done this by using the property visible. but the space for this textbox is still available there. I want to hide that space also.

推荐答案

你不能这么做太容易了 - 因为没有自动移动方法所以需要一些工作它下面的控件向上或向下。

你可以通过锚定所有必须向上移动到窗体底部的控件,或者包含它们的面板,然后缩小高度来实现它表单/面板,但大多数时候会为用户创建一个令人困惑的外观 - 特别是如果导致这种情况的按钮也会移动!



通常情况下,最好使用相反,启用属性将控件留在那里,但向用户显示它不可用。
You can't do that, too easily - it takes a bit of work because there is no automatic way to move all the controls below it upwards or downwards.
You can do it, by anchoring all the controls that have to move up to the bottom of the form, or a panel containing them all and then shrinking the height of the form / panel but most times that creates a confusing appearance for the user - particularly if the button that causes this moves as well!

Normally, it is better to use the Enable property instead which leaves the control there, but shows the user it is not available for use.


这篇关于c#中的show \hide控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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