myButton.Location = new Point ( btnAdd.Location.X , locY ) ; 
http://www.yesky.com/SoftChannel/72342380468109312/20020114/213862_1.shtml

解决方案 »

  1.   

    他会提示要放在runat="server"内的,代码我是直接放在
    private void Page_Load(object sender, System.EventArgs e)里写的
      

  2.   

    aspx文件
    <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="test.WebForm1" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title>WebForm1</title>
    <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
    <meta name="CODE_LANGUAGE" Content="C#">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    </HEAD>
    <body MS_POSITIONING="GridLayout">
    <form id="Form1" method="post" runat="server">
    <asp:Panel id="Panel1" style="Z-INDEX: 101; LEFT: 320px; POSITION: absolute; TOP: 232px" runat="server"
    Width="240px" Height="120px">Panel</asp:Panel>
    </form>
    </body>
    </HTML>
    aspx.cs文件
    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;namespace test
    {
    /// <summary>
    /// WebForm1 的摘要说明。
    /// </summary>
    public class WebForm1 : System.Web.UI.Page
    {
    protected System.Web.UI.WebControls.Panel Panel1;
    public TextBox TextBox1;

    private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面
    TextBox1=new TextBox();
    Panel1.Controls.Add(TextBox1); } #region Web 窗体设计器生成的代码
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {    
    this.Load += new System.EventHandler(this.Page_Load); }
    #endregion
    }
    }
    就可以了,问人真是很难表达清楚啊
      

  3.   

    TextBox1=new TextBox();
    Controls.Add(TextBox1);
    TextBox1.Visable=true;
    TextBox1.Location=//自定义到自己想要的位置,问题一般会出现在这里。
      

  4.   

    TextBox1.Location=//自定义到自己想要的位置,问题一般会出现在这里。
    如何定义位置?
      

  5.   

    TextBox1=new TextBox();
    Controls.Add(TextBox1);
    TextBox1.Visable=true;
    TextBox1.Location=//自定义到自己想要的位置,问题一般会出现在这里。补充一点 还要加一句话才行:TextBox1.BringToFront();加在一个按钮的点击事件中,点击按钮能出一个textbox1就对了