|
|
|
รบกวนดูโค้ดให้หน่อยคะ DataGridViewCheckBoxColumn ต้องการ remove ออกเฉยๆ คะพอติ๊ก checkbox แต่มันไม่ทำงานคะ |
|
|
|
|
|
|
|
โค้ดคะ
Code (C#)
private void btnShip_Click(object sender, EventArgs e)
{
sb = new StringBuilder();
sb.Remove(0, sb.Length);
sb.Append("SELECT [Receive Order].ROId,Customer.CustomerName, Customer.CustomerAddress, ");
sb.Append("[Receive Order].ROSDate, [Receive Order].TotalAmountOrder ");
sb.Append("FROM [Receive Order] INNER JOIN ");
sb.Append("Customer ON [Receive Order].CustomerId = Customer.CustomerId ");
sb.Append("GROUP BY [Receive Order].ROId,Customer.CustomerName, Customer.CustomerAddress, ");
sb.Append("[Receive Order].ROSDate, [Receive Order].TotalAmountOrder ");
sb.Append(" ORDER BY [Receive Order].ROId ");
string sqlProduct = sb.ToString();
com = new SqlCommand();
com.Parameters.Clear();
com.CommandText = sqlProduct;
com.CommandType = CommandType.Text;
com.Connection = Conn;
dr = com.ExecuteReader();
if (dr.HasRows)
{
dgvShip.ReadOnly = false;
chkCol.Name = "chkselect";
chkCol.HeaderText = " ";
chkCol.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
chkCol.TrueValue = true;
chkCol.Width = 10;
chkCol.DisplayIndex = 18;
chkCol.FlatStyle = FlatStyle.Popup;
dgvShip.Columns.Add(chkCol);
/*for (int i = dgvShip.Rows.Count - 1; i >= 0; i--)
{
if ((bool)dgvShip.Rows[i].Cells[0].FormattedValue)
{
dgvShip.Rows.RemoveAt(i);
}
}*/
foreach (DataGridViewRow row in dgvShip.Rows)
{
if ((bool)row.Cells[0].Value)
{
dgvShip.Rows.Remove(row);
}
}
//DataGridViewButtonColumn btn = new DataGridViewButtonColumn();
//dgvShip.Columns.Add(btn);
//btn.HeaderText = "Click Data";
//btn.Text = "เรียบร้อย";
//btn.Name = "btn";
//btn.UseColumnTextForButtonValue = true;
DataTable dtPoHard = new DataTable();
dtPoHard.Load(dr);
CheckResult = dtPoHard.Rows.Count;
dgvShip.DataSource = dtPoHard;
HeadData();
}
else
{
CheckResult = 0;
dgvShip.DataSource = null;
}
lblCheckProduct.Text = "พบ : " + CheckResult.ToString() + " รายการ";
dr.Close();
}
Tag : .NET
|
|
|
|
|
|
Date :
2013-06-11 12:10:58 |
By :
yhong_k |
View :
797 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ไม่ Debug ดูครับ ว่ามันทำงานหรือเปล่าครับ
|
|
|
|
|
Date :
2013-06-11 20:49:42 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|