1、我没有装VS.NET
2、This.Quit();

解决方案 »

  1.   

    1、请给出源程序。
    2、this第一个字母是小写。
      

  2.   

    在class文件里调用窗体的控件是要带上窗体的句柄。
    应该是this.Close();吧
      

  3.   

    1.加using....... or 直接用System.web.UI.........
    2.this.Close();
      

  4.   

    需要把窗体对象的引用传到另外一个类。然后再用RefObj.Close();以前有过这样的贴子,看看以前的贴子吧。
      

  5.   

    1.以下是我在新加的类中访问窗体上控件的方法
        Form1 frm=new Form1();
        frm.textBox1.Text="gdgd";
      Form1是窗体的缺省类。
    2. this.Close()是可以的,检查一下大小写
      

  6.   

    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;
    using System.Net.Sockets;
    using System.Threading;namespace PortScan
    {
    public class frmScan : System.Windows.Forms.Form
    {
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.TextBox txtAddr;
    private System.Windows.Forms.Label label2;
    private System.Windows.Forms.Label label3;
    public System.Windows.Forms.ListBox lstPutout;
    private System.Windows.Forms.Button btnScan;
    private System.Windows.Forms.Button btnStop;
    private System.Windows.Forms.TextBox txtStart;
    private System.Windows.Forms.TextBox txtEnd; private System.ComponentModel.Container components = null; public class clPortScan
    {
    public int port;
    public string Addr;
    public bool[] done=new bool[65536];
    public void Scan()
    {
    int portnow=port;
    done[portnow]=false;
    TcpClient objTCP=new TcpClient();
    frmScan objFrm=new frmScan();
    try
    {
    objTCP.Connect(Addr,portnow);
    objFrm.lstPutout.Items.Add("port"+portnow.ToString()+"is open!");
    }
    catch(SocketException)
    {
    objFrm.lstPutout.Items.Add("port"+portnow.ToString()+"isn't open!");
    done[portnow]=true;
    }
    objFrm.Close();
    }
    } public frmScan()
    { InitializeComponent(); } protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null) 
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region Windows Form Designer generated code
    private void InitializeComponent()
    {
    ......
    }
    #endregion [STAThread]
    static void Main() 
    {
    Application.Run(new frmScan());
    } private void btnScan_Click(object sender, System.EventArgs e)
    {
    lstPutout.Items.Add("PortScanner v0.1");
    lstPutout.Items.Add(" ");
    int start=Convert.ToInt32(txtStart.Text.Trim());
    int end=Convert.ToInt32(txtEnd.Text.Trim());
    if((start>=0 && start<=65536) && (end>=0 && end<=65536))
    {
    int i;
    lstPutout.Items.Add(("Starting scan...(this may take a few minutes)"));
    clPortScan objPortscan=new clPortScan();
    objPortscan.Addr=txtAddr.Text.Trim();
    for (i=start;i<=end;i++)
    {
    objPortscan.port=i;
    Thread scanThread=new Thread(new ThreadStart(objPortscan.Scan));
    scanThread.Start();
    System.Threading.Thread.Sleep(1000);
    }
    lstPutout.Items.Add("Scan complete.");
    }
    else
    {
    lstPutout.Items.Add("start/end scan range is out of range[0-65536]");
    }
    } private void btnStop_Click_1(object sender, System.EventArgs e)
    {
    this.Close();
    }
    }
    }
      

  7.   

    //上面是部分的源代码,经过大家的修正,已经通过编译,类clPortScan已经可以使用窗体类frmScan中的lstPutout控件,this.close也可以关闭窗体。
    多谢大家了!但是运行过程中还有些问题,类clPortScan中的   objFrm.lstPutout.Items.Add("port"+portnow.ToString()+"isopen!");    ————向窗体中的listbox控件中添加字符串
    检测到该语句已经运行,但是在窗体中的listbox控件中并没有任何反应。
    窗体类中相似的语句却可以,不知道是什么原因?