private void new_button_Click(object sender, EventArgs e)
{
Button button = new Button();
button.Location = new System.Drawing.Point(411, 334);
button.Name = "my_button";
button.Size = new Size(100, 100);
button.TabIndex = 1;
button.Text = "This is my new one.";
button.UseVisualStyleBackColor = true;
button.Visible = true;
}
{
Button button = new Button();
button.Location = new System.Drawing.Point(411, 334);
button.Name = "my_button";
button.Size = new Size(100, 100);
button.TabIndex = 1;
button.Text = "This is my new one.";
button.UseVisualStyleBackColor = true;
button.Visible = true;
}
解决方案 »
- 我用格式“F4”,结果数据“12.5120”在DataGridView单元格中显示为“12.512”,最后一位0被省掉了,如何保留最后一位0
- 语法错误 (操作符丢失) 在查询表达式 '2011-5-22 22:11:24' 中。哪位高手可以帮我!
- 怎么继承泛型接口
- 请教各位一个小问题
- 线程 sleep问题
- 求助:excel输出时的格式问题
- 调用VC的DLL参数类型问题
- 定时用WebBrowser去请求一个页面的问题
- 哪位能提供VS.NET中的IE控件的使用帮助文档?
- 如何在ComboBox项中添加text,和value?
- 调查一下:我想做个smtp代理服务器,实现邮件的分割,大家觉得实用(值得)么?
- 两台并非集群的服务器,如何动态选择在线的服务器?
button.Parent = this;
我试了..还是不行...如下代码:
private void new_button_Click(object sender, EventArgs e)
{
Button button = new Button();
button.Location = new System.Drawing.Point(411, 334);
button.Name = "my_button";
button.Size = new Size(100, 100);
button.TabIndex = 1;
button.Text = "This is my new one.";
button.UseVisualStyleBackColor = true;
button.Visible = true;
button.Parent = this;
button.
}
form1.controls.add(button);
你没有放到窗体上
this.Controls.Add(button);
using System;
using System.Windows.Forms;class Program : Form
{
private void new_button_Click(object sender, EventArgs e)
{
Button button = new Button();
button.Location = new System.Drawing.Point(411, 334);
button.Name = "my_button";
button.Size = new System.Drawing.Size(100, 100);
button.TabIndex = 1;
button.Text = "This is my new one.";
button.UseVisualStyleBackColor = true;
button.Parent = this;
}
Program()
{
Size = new System.Drawing.Size(550, 440); Button button = new Button();
button.Size = new System.Drawing.Size(100, 100);
button.Text = "Click me";
button.UseVisualStyleBackColor = true;
button.Parent = this;
button.Click += new EventHandler(new_button_Click);
}
// 程序入口
static void Main()
{
Application.Run(new Program());
}
}
this.Controls.Add(button);
button.Parent = this;和this.Controls.Add(button);是等效的,两者只要用一个就可以了。