  | 
              
	              
	                
  
    |   | 
   
  
    
        
        มีวิธีทำให้ข้อมูลในdatagridview ลงใน textbox ตามลำดับตอนเรากด button ไหมครับ     | 
   
  
    |   | 
   
 
 
 
              
  
          
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ทำไมไม่เป็น ชื่อคนที่ 1 ชื่อคนที่ 3 ชื่อคนที่ 4 หรือ อื่นๆ พอจะรู้เหตุผลไม๊ครับ                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2018-05-24 16:08:26 | 
                        By :
                            lamaka.tor | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                   ตอบความคิดเห็นที่ : 1 เขียนโดย : lamaka.tor เมื่อวันที่ 2018-05-24 16:08:26 
รายละเอียดของการตอบ ::
  แบบเพิ่มครั้งเดียวว 1,2,3,4 อย่างงี้หรอครับอันนี้ใช้แค่ไฟล์เดียวแล้วส่งเป็นกลุ่มอะครับอันนี้สามารถทำได้ครับ 
แต่ requirement ที่ได้คือ 1ไฟล์ต่อ1user ซึ่งต้องกดส่งแล้วก็ต้องมา เลือก email user ใน gridview ซ้ำเรื่อยๆ อะครับ 
 
ตัวโค้ดครับ 
 Code (C#)
        private void button1_Click(object sender, EventArgs e)
        {
            send_mail();
        }
        public void send_mail()
        {
            MailMessage mail = new MailMessage(textBox1.Text, textBox3.Text.Replace(";", ","));
            mail.From = new MailAddress(textBox1.Text);
            mail.To.Add(textBox3.Text);
            mail.Subject = textBox5.Text;
            mail.Body = textBox4.Text;
            if (textBox6.Text != "")
            {
                mail.Attachments.Add(new Attachment(textBox6.Text));
            }
            //"imap.inetmail.cloud"
            SmtpClient smtpServer = new SmtpClient("xxxx.xxxxx.com");
            smtpServer.UseDefaultCredentials = true;
            //smtpServer.Credentials = new System.Net.NetworkCredential(textBox1.Text, textBox2.Text);
            smtpServer.Port = 25;
            smtpServer.Host = "xx.xx.xx.xxx";
            smtpServer.EnableSsl = checkBox1.Checked;
            //mail = null;
            try
            {
                smtpServer.Send(mail);
                MessageBox.Show("Mail Send Success Fully");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message,"Information");
            }
        }
        public void mem_ber()
        {
            Connect_Base.connectionsql_1();
            SqlConnection constring = new SqlConnection(Connect_Base.strcon);
            constring.Open();
            constring.Close();
            DataTable dtable = Connect_Base.excute_1("SELECT mem_id,fname,lname,email FROM mem_member WHERE email != ''");
            dataGridView1.DataSource = dtable;
            constring.Open();
            DataGridViewCheckBoxColumn chk = new DataGridViewCheckBoxColumn();
            dataGridView1.Columns.Add(chk);
        }
        private void button2_Click(object sender, EventArgs e)
        {
            mem_ber();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            this.textBox1.Text = "[email protected]";
            //this.textBox2.Text = "xxxxxxxxxx";
        }
        private void button3_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                string path = ofd.FileName.ToString();
                textBox6.Text = path;
            }
        }
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            /*if (e.ColumnIndex == 4)//set your checkbox column index instead of 2
            {
                    if (e.RowIndex >= 0)
                    {
                        DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex];
                        textBox3.Text += row.Cells["email"].Value.ToString() + ",";
                    }
            }*/
            //We make DataGridCheckBoxColumn commit changes with single click
            //use index of logout column
            if (e.ColumnIndex == 4 && e.RowIndex >= 0)
            {
                this.dataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit);
                DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex];
                textBox3.Text += row.Cells["email"].Value.ToString();
            }
        }
                        
               
               | 
             
            
              
			                
  ประวัติการแก้ไข 2018-05-25 09:16:43              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2018-05-25 09:15:54 | 
                        By :
                            darkgolfman0 | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
      		  
	
     | 
   
 
                 |