C#隐藏在启动新业态 [英] C# Hide new Form at start

查看:170
本文介绍了C#隐藏在启动新业态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IHAVE一种形式,是隐藏的,这个加载子窗体的2E形式应该被隐藏藏汉



请注意事项:我最不使用



  ShowInTaskbar = FALSE; //应该被隐藏得

和我最能如果我使用形式之间的通信(隐藏/可见),我不能,直到它的可见=真正的交流;

  this.SetParameterValueCallback + =新SetParameterValueDelegate(ShowMain.SetParamValueCallbackFn); 
ShowMain.AddItemCallback =新AddItemDelegate(this.AddItemCallbackFn);
//Showsub.Show();
Showsub.Hide(); //没有工作



我已经试过到目前为止

  THIS.VISIBLE = FALSE; //没有工作

的BeginInvoke(新MethodInvoker(代表
{
隐藏();
})); //没有工作

base.SetVisibleCore(假); //没有工作,我不是能形式
之间进行通信


解决方案

我真的不明白,为什么你就可以使它在一个工作,而不是其他。从得到时可见它的Show()方法被调用防止表单需要重写SetVisibleCore方法。也许你可以利用此代码:

 私人布尔mAllowVisible = FALSE; 

公共BOOL ReallyVisible {
{返回mAllowVisible; }
集合{
mAllowVisible =价值;
如果(值)THIS.VISIBLE = TRUE;
}
}

保护覆盖无效SetVisibleCore(布尔值){
如果(价值和放大器;&安培;!IsHandleCreated)CreateHandle(); //确保Load事件运行
如果值= FALSE(ReallyVisible!);
base.SetVisibleCore(值);
}


Ihave a form which is hidden and this loads a subform the 2e form should be hidden aswell

Please notes: I most not use

ShowInTaskbar = false; //  should be hidden too

and I most be able to communicate between forms if I use (hide/visible) i cant communicate until its visible = true;

  this.SetParameterValueCallback += new SetParameterValueDelegate(ShowMain.SetParamValueCallbackFn);
        ShowMain.AddItemCallback = new AddItemDelegate(this.AddItemCallbackFn);
        //Showsub.Show();
        Showsub.Hide(); // not working

I have tried so far

this.Visible = false; // didnt work

 BeginInvoke(new MethodInvoker(delegate
            {
                Hide();
            })); // didnt work

base.SetVisibleCore(false); // didnt work, Im not able communicate between form

解决方案

I don't really understand why you would be able to make it work in one but not the other. Preventing a form from getting visible when its Show() method is called requires overriding the SetVisibleCore method. Perhaps you can leverage this code:

private bool mAllowVisible = false;

public bool ReallyVisible {
  get { return mAllowVisible; }
  set {
    mAllowVisible = value;
    if (value) this.Visible = true;
  }
}

protected override void SetVisibleCore(bool value) {
  if (value && !IsHandleCreated) CreateHandle();  // Ensure Load event runs
  if (!ReallyVisible) value = false;
  base.SetVisibleCore(value);
}

这篇关于C#隐藏在启动新业态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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