2011-08-10 75 views

回答

1

如果要隱藏在用戶點擊一個按鈕,使用的DataGridView的CellClick事件,像這樣的DataGridViewRow:

private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { 
    // After you've verified that the column clicked contains the button you want to use to hide rows... 

    CurrencyManager currencyManager1 = (CurrencyManager)BindingContext[dataGridView1.DataSource]; 
    currencyManager1.SuspendBinding(); 

    dataGridView1.Rows[e.RowIndex].Visible = false; 

    currencyManager1.ResumeBinding(); 
} 

請注意,您需要暫停數據綁定到該行的Visible屬性設置爲false 。

要顯示已經隱藏重新綁定您的DataGridView中的所有行:

dataGridView1.DataSource = null;   
dataGridView1.DataSource = yourDataTable; 
+0

謝謝您的答覆Sir.Well先生,這是工作Perfect.And我現在需要一個DataGridViewButtonColumn意味着當單擊時按鈕,那麼只有它應該隱藏不當我點擊總行。 – tiru

相關問題