如何在c#中隐藏USER CONTROL(help!help !! help !!!) [英] How to hide USER CONTROL in c# (help! help!! help!!! .)

查看:57
本文介绍了如何在c#中隐藏USER CONTROL(help!help !! help !!!)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
       {
           panel2.Controls.Clear();
           panel2.Visible = true;
           forgotpass r1 = new forgotpass();
           r1.Show();
           panel2.Controls.Add(r1);

       }





如果我使用ff.hide它不隐藏,我需要隐藏 forgotpass USER CONTROL隐藏....







if i use "ff.hide" its not hiding, i need to hide this forgotpass USER CONTROL to be hide....


.

推荐答案

您必须至少在面板的控件集合中引用usercontrol或知道其索引。



You must have a reference to the usercontrol or know its index in the panel''s controls collection at least.

forgotpass ff; //or int ffIndex;

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
     panel2.Controls.Clear();
     panel2.Visible = true;
     ff = new forgotpass();
     ff.Show();
     panel2.Controls.Add(ff);
     // ffIndex=panel2.Controls.IndexOf(ff);
}
 
void HideFF() 
{
    ff.hide(); // or panel2.Controls[ffIndex].hide();
}


将属性的可见性设置为Visibility.Collapsed



set the Visibility of a property to Visibility.Collapsed

control.Visibility = Visibility.Collapsed





这将隐藏和删除它所占用的控件空间



希望这有助于



this will hide and remove the space of the control that it is occupying

hope this helps


这篇关于如何在c#中隐藏USER CONTROL(help!help !! help !!!)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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