من يك فرم دارم و يك دكمه روي اون فرم. اين كدها رو ميخوام درك كنم
namespace WindowsFormsApplication7
{
partial class Form1
{
///<summary>
/// Required designer variable.
///</summary>
private System.ComponentModel.IContainer components = null;
///<summary>
/// Clean up any resources being used.
///</summary>
///<param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
///<summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///</summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(79, 42);
this.button1.Name = "button2";
this.button1.Size = new System.Drawing.Size(118, 43);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 262);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button button1;
}
}
چندتا جاش برام نا مفهومه:
1- ما مگه ننوشتيم
private System.Windows.Forms.Button button1;
پس اين ديگه چه معنيي داره؟this.button1.Name = "button2"
ما مگه اسم آبجكتي رو كه ايجاد كرديم همون موقع نذاشتيم button1 پس چرا name رو به عنوان يك پروپرتي در كلاس button در نظر گرفتن. بر فرض اگه عوضش كنيم چي ميشه؟!
2-متد Dispose كارش چيه؟
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
3- اينها چيه؟
#region Windows Form Designer generated code
#endregion
4- اين چيه؟
private System.ComponentModel.IContainer components = null
در جاي ديگه اي هم اين كد وجود داره
namespace WindowsFormsApplication7
{
publicpartialclassForm1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
1-فضاي نام اين و بالاييه يكيه تنها تفاوتش توي كلاس هست كه كلاس پايين يك ارث بري كرده كه كلاس بالا نكرده. ميشه گفت اين دو سري كد كنار همن؟
2- فرم كامپوننت نيست. پس دقيقا چيه؟ ما براي ايجاد يك دكمه يك كدي نوشتيم. فرم رو چطور تشخيص ميده؟
3- براي دكمه خصوصيات زيادي وجود داره اما اينجا فقط چندتا دونشون رو مقدار داده. دليل چيه؟ بقيه كجا مقدار داده ميشن؟