foreach (DataGridViewRow row in dataGridView1.Rows) { if (Convert.ToBoolean(row.Cells[0].Value) == true) { MessageBox.Show(row.Index.ToString()); } }
private void dataGridView1_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { bill_date_pass = dataGridView1.Rows[0].Cells[1].Value.ToString(); //วิธีการเดิม }
private string bill_date; public string bill_date_pass { get { return bill_date; } set {bill_date=value; } }
dataGridView1.Rows[dataGridView1.Rows.Count - 2].Cells[0].Value =form2.bill_date_pass;
public bool[] status
//เอาไปไว้ในform1 foreach (DataGridViewRow row in form2.dataGridView1.Rows) { if (Convert.ToBoolean(row.Cells[0].Value) == true) { dataGridView1.Rows.Add(row.Cells[1].Value,row.Cells[2].Value); } }
private string[] bill_parameter = new string[5]; public string bill_date_pass { get { return bill_parameter[0]; } set { bill_parameter[0] = value; } }
private void button2_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in dataGridView1.Rows) { if (Convert.ToBoolean(row.Cells[0].Value) == true) { int countrow,totalcount; countrow = 0; totalcount = countrow + 1; for (int i = countrow; i < totalcount; i++) { bill_parameter[i] = dataGridView1.Rows[row.Index].Cells[1].Value.ToString(); MessageBox.Show(bill_parameter[i]); } //end for } } //end foreach this.Hide(); }
dataGridView3.Rows[dataGridView3.Rows.Count - 2].Cells[1].Value = abtrpt.bill_date_pass; // นำเข้า ค่าจาก form2 แบบเก่า แล้วถ้ามันเป็นอาเรย์ละครับ if (dataGridView4.Rows[0].Cells[0].Value != null) { try { dataGridView3.Rows.Add(""); // อันนี้เป็นการเพิ่ม rows แบบเก่า เพราะเราเปิดมา เลือกทีละ 1 rows แต่ คราวนี้มาเป็น array เราจะมีวิธีเพิ่ม rows อย่างไรครับ } catch (Exception) { } }
private void Form1_Load(object sender, EventArgs e) { Form2 f = new Form2(); f.ShowDialog(); //ควรจะ Clear DataGridView ก่อน DataGridView1.Rows.Clear(); //ดึงเอาข้อมูลจาก Form2 มาใช้งาน foreach (DataGridViewRow row in f.DataGridView1.Rows) { if (Convert.ToBoolean(row.Cells[0].Value) == true) { DataGridView1.Rows.Add(new object[]{row.Cells[1].Value.ToString(), row.Cells[2].Value.ToString()}); } } } //จบโค๊ดแบบบ้านๆครับ แค่รอบเดียวไม่ต้องยุ่งยากเรียก array มาใช้งานให้เปลือง เมม
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง