c# 方法或属性之间的呼叫模稜两可
在网上找了一个GUI例子该例子中有一个文本框,两个按钮,单击“点击我”的按钮在文本框中显示“你好,电脑报”。单击“终结者”的按钮结束程序。
在
Form1(){
InitializeComponent(); //初始化窗体及子控件
}
private void InitializeComponent()
{
...
}
提示方法或属性之间的呼叫模稜两可。
新手求教! 没懂 顶 ibcadmin 发表于 2014-8-12 12:41
没懂
就是在Form1中調用IntializeComponent()方法時有錯誤信息:方法或属性之间的呼叫模稜两可 tanks22 发表于 2014-8-14 07:13
就是在Form1中調用IntializeComponent()方法時有錯誤信息:方法或属性之间的呼叫模稜两可
你的 终结者 按钮事件是怎么写的 ibcadmin 发表于 2014-8-14 19:59
你的 终结者 按钮事件是怎么写的
C#入門教程里的一個例子
namespace Test
{
public class Form1 : Form
{
private TextBox textBox1;
private Button button1;
private Button button2;
private Container components = null;
public Form1()
{
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()
{
this.textBox1 = new TextBox();
this.button1 = new Button();
this.button2 = new Button();
this.SuspendLayout();
//textBox1
this.textBox1.Location = new Point(74, 64);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new Size(144, 21);
this.textBox1.TabIndex = 0;
this.textBox1.Text = "C#酷嗎?";
//button1
this.button1.Location = new Point(58, 160);
this.button1.Name = "button1";
this.button1.Size = new Size(72, 74);
this.button1.Text = "點擊我";
this.button1.Click += new System.EventHandler(this.button1OnClick);
//button2
this.button2.Location = new Point(162, 160);
this.button2.Name = "button2";
this.button2.Size = new Size(72, 74);
this.button2.Text = "終結者";
this.button2.Click += new System.EventHandler(this.button2OnClick);
//form1
this.AutoScaleBaseSize = new Size(6, 14);
this.ClientSize = new Size(292, 273);
this.Controls.AddRange(new Control[]{
this.button2,
this.button1,
this.textBox1});
this.Name = "Form1";
this.Text = "我愛C#";
this.ResumeLayout(false);
}
#endregion
static void main(){
Application.Run(new Form1());//啟動程序
}
//響應單擊按鈕“點擊我”的button1OnClick事件
private void button1OnClick(object sender, EventArgs e){
textBox1.Text = "你好!電腦報";
}
//響應單擊按鈕“終結者”的button2OnClick事件
private void button2OnClick(object sender, EventArgs e){
Application.Exit();//退出應用程序
}
}
} 你写错了, 除了Click的事件, 其他全是系统生成的 你这样写会跟系统重复的 ibcadmin 发表于 2014-8-15 09:18
你写错了, 除了Click的事件, 其他全是系统生成的 你这样写会跟系统重复的
好吧,在C#的道路上慢慢探尋把,謝了啊!
页:
[1]