文本框不是有Click事件吗?在事件处理函数中把name属性赋予另外一个文本框不就行了?

解决方案 »

  1.   

    你需要enum所有的control,然后在这个循环内设置:myControl.Click = SomeFunc(...)
    SomeFunc(...)中设置:ThisLabel.Text = myControl.Name;大意如此
      

  2.   

    我的意思是:我需要动态在窗体上生成控件(如文本框、或列表框……)
    然后能够随意双击生成的控件,又能够 Remove 此控件。该如何,可不可以写出大意代码?
      

  3.   

    //Generate the new button, and add to webform
    private void Button1_Click(object sender, System.EventArgs e)
    {
    System.Web.UI.WebControls.Button b1;
    b1=new System.Web.UI.WebControls.Button();
    b1.Style.Add("top","100px");
    b1.Style.Add("left","100px");
    b1.Style.Add("Position","Absolute");
    b1.Visible=true;
    b1.Width=40;
    b1.Height=40;
    b1.Text="click to remove me ";
    b1.Click+=new System.EventHandler(this.RemoveButton);
        Button1.Parent.Controls.Add(b1); }
    //remove the button from the webform
    void RemoveButton(object sender,System.EventArgs e)
    {
    if (sender.GetType().Equals("System.Web.UI.WebControls.Button"))
    {
    System.Web.UI.WebControls.Button b1;
    b1=(System.Web.UI.WebControls.Button)sender;
    b1.Parent.Controls.Remove(b1);
    b1.Dispose();
    }

    }