This.Close();不按钮工作 [英] This.Close(); not working in button

查看:202
本文介绍了This.Close();不按钮工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

This.Close();



此代码无法使用按钮。





结构如下:



protected void btn_Close_Click(object sender,EventArgs e)

{

close();

}






当你开始输入'close'时,智能感知甚至不弹出。



请帮助

解决方案

< blockquote>如果您的代码在Form中,而不是UserControl,它将起作用:

  this  .Close(); 

但是,在这种情况下你不需要这个,暗示了这个实例:

 Close(); 

将产生相同的效果。



如果你在UserControl中,那么你将要创建一个事件来要求表格关闭:你不应该试图自己关闭它。


  protected   void  btn_Close_Click( object  sender,EventArgs e)
{
this .close(); // 这是代码中的问题。
}


This.Close();

This codes are not working in button.


The construct is as follows :

protected void btn_Close_Click(object sender, EventArgs e)
{
close();
}



Infact the Intellisense those not even pop-up when you start typing 'close'.

Pls assist

解决方案

Provided your code is inside a Form, rather than a UserControl, it will work:

this.Close();

However, you don't need this in that context, the instance is implied:

Close();

will have the same effect.

If you are in a UserControl, then you will have to create an event to ask the form to close: you shouldn't try to shut it yourself.


protected void btn_Close_Click(object sender, EventArgs e)
{
this.close(); //this is the problem in your code.
}


这篇关于This.Close();不按钮工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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