  | 
              
	              
	                
  
    |   | 
   
  
    
        
        สอบถามเรื่องวิธีการเพิ่ม object ในฟรอม กับการใช้งานชื่อ object หลายๆอันในฟั่งชั่น ครับ     | 
   
  
    |   | 
   
 
 
 
              
  
          
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ทำเป็น Usercontrol ครับ 
คร่าวก็ประมาณนี้ครับ 
 
Code (C#) 
public partial class PanelTable : UserControl
    {
        public PanelTable()
        {
            InitializeComponent();
        }
    }
 partial class PanelTable
    {
        /// <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 Component 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.lblTime = new System.Windows.Forms.Label();
            this.lblCusCount = new System.Windows.Forms.Label();
            this.lblTable = new System.Windows.Forms.Label();
            this.button2 = new System.Windows.Forms.Button();
            this.button3 = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // button1
            // 
            this.button1.Location = new System.Drawing.Point(105, 10);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(39, 23);
            this.button1.TabIndex = 0;
            this.button1.Text = "+";
            this.button1.UseVisualStyleBackColor = true;
            // 
            // lblTime
            // 
            this.lblTime.AutoSize = true;
            this.lblTime.Location = new System.Drawing.Point(12, 10);
            this.lblTime.Name = "lblTime";
            this.lblTime.Size = new System.Drawing.Size(35, 13);
            this.lblTime.TabIndex = 1;
            this.lblTime.Text = "label1";
            // 
            // lblCusCount
            // 
            this.lblCusCount.AutoSize = true;
            this.lblCusCount.Location = new System.Drawing.Point(12, 29);
            this.lblCusCount.Name = "lblCusCount";
            this.lblCusCount.Size = new System.Drawing.Size(35, 13);
            this.lblCusCount.TabIndex = 2;
            this.lblCusCount.Text = "label2";
            // 
            // lblTable
            // 
            this.lblTable.AutoSize = true;
            this.lblTable.Location = new System.Drawing.Point(12, 53);
            this.lblTable.Name = "lblTable";
            this.lblTable.Size = new System.Drawing.Size(35, 13);
            this.lblTable.TabIndex = 3;
            this.lblTable.Text = "label3";
            // 
            // button2
            // 
            this.button2.Location = new System.Drawing.Point(150, 10);
            this.button2.Name = "button2";
            this.button2.Size = new System.Drawing.Size(39, 23);
            this.button2.TabIndex = 4;
            this.button2.Text = "-";
            this.button2.UseVisualStyleBackColor = true;
            // 
            // button3
            // 
            this.button3.Location = new System.Drawing.Point(105, 48);
            this.button3.Name = "button3";
            this.button3.Size = new System.Drawing.Size(84, 23);
            this.button3.TabIndex = 5;
            this.button3.Text = "Cal";
            this.button3.UseVisualStyleBackColor = true;
            // 
            // PanelTable
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(224)))), ((int)(((byte)(192)))));
            this.Controls.Add(this.button3);
            this.Controls.Add(this.button2);
            this.Controls.Add(this.lblTable);
            this.Controls.Add(this.lblCusCount);
            this.Controls.Add(this.lblTime);
            this.Controls.Add(this.button1);
            this.Name = "PanelTable";
            this.Size = new System.Drawing.Size(191, 74);
            this.ResumeLayout(false);
            this.PerformLayout();
        }
        #endregion
        private System.Windows.Forms.Button button1;
        private System.Windows.Forms.Label lblTime;
        private System.Windows.Forms.Label lblCusCount;
        private System.Windows.Forms.Label lblTable;
        private System.Windows.Forms.Button button2;
        private System.Windows.Forms.Button button3;
    }
 
 
เพิ่ม property,event แล้วก็ลากวางๆๆๆ ได้เลย ครับ                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2017-06-24 23:56:22 | 
                        By :
                            lamaka.tor | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                   ตอบความคิดเห็นที่ : 1 เขียนโดย : lamaka.tor เมื่อวันที่ 2017-06-24 23:56:22 
รายละเอียดของการตอบ ::
  
ผมลองก๊อปโคตไปรันดูแล้ว มันเพิ่มได้ อันเดียวอะครับ อยากให้มันเพิ่มได้เรื่องๆ จารผมสั่งมาแบบนั้นครับ
 
ผมยังไม่ค่อยเข้าใจมันทำงานยังไงครับ ช่วยทีครับ
 
      this.button1 = new System.Windows.Forms.Button(); อันนี้ สร้างให้ "button1" มัน = เป็นตัวแทนของ button ในฟรอมนี้ใช้ไหมครับ 
      หรือว่า สร้างให้มันเป็นตัวแปล ที่ทำหน้าที่แทน object ครับ
   
 
    this.button1.Location = new System.Drawing.Point(105, 10);   อันนี้น่าจะเกี่ยวกับตำแหน่ง
 
            this.button1.Name = "button1";                                     อันนี้ใส่ชื่อปุ่ม ที่เป็น objectใช่ไหมครับ อย่างปุ่ม button7
 
            this.button1.Size = new System.Drawing.Size(39, 23);    อันนี้ขนาด 
            this.button1.TabIndex = 0; 
            this.button1.Text = "+"; 
            this.button1.UseVisualStyleBackColor = true;
 
อันอื่นด้วยครับ
                         
               
               | 
             
            
              
			                
  ประวัติการแก้ไข 2017-06-25 00:51:10              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2017-06-25 00:41:40 | 
                        By :
                            gazutumn | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	     
	    
     
      		  
	
     | 
   
 
                 |