还有最后一个问题,我发现这种方式用在MDI窗体上就没有效果了,
打开代码如下
Ainventory ait = new Ainventory(sql);
ait.ShowInTaskbar = false;//不显示窗体
ait.ShowDialog();
重载的代码如下
public Ainventory(string sql2)
{
InitializeComponent();
dsql2 = sql2;
//建立一个按钮返回确定
Button bt = new Button();
bt.DialogResult = DialogResult.OK;
bt.Visible = true;
bt.Height = 50;
bt.Width = 50;
bt.Left = 900;
bt.Top = 500;
bt.Text = "确定";
this.Controls.Add(bt);
}
结果没有发现出来有button, 不知道是不是因为Ainventorye 有其它控件,把它给遮住了,如果我想提到最长层该如何弄呢
打开代码如下
Ainventory ait = new Ainventory(sql);
ait.ShowInTaskbar = false;//不显示窗体
ait.ShowDialog();
重载的代码如下
public Ainventory(string sql2)
{
InitializeComponent();
dsql2 = sql2;
//建立一个按钮返回确定
Button bt = new Button();
bt.DialogResult = DialogResult.OK;
bt.Visible = true;
bt.Height = 50;
bt.Width = 50;
bt.Left = 900;
bt.Top = 500;
bt.Text = "确定";
this.Controls.Add(bt);
}
结果没有发现出来有button, 不知道是不是因为Ainventorye 有其它控件,把它给遮住了,如果我想提到最长层该如何弄呢
Button是否存在
bt.Location=new Point(0, 0);
bt.Location=new Point( (int)this.Width/2,(int)this.Height/2)
messagebox.Show(bt.Text)
如果生成了再搞定位置
bt.Location = Ainventorye.PointToScreen(new System.Drawing.Point(x,y));
btn.Text="";
btn.name="btn";
btn.location=new point(10,10);
btn.Click+=new EventHandler(btn_Click);
this.Controls.Add(btn);大概这样子了!