任何人都可以告訴我如何根據選定的單選按鈕過濾Datagridview,我附上了我創建的窗體的屏幕截圖,需要根據存取情況進行過濾。我已將TransactionType作爲枚舉。c#windows窗體使用RadioButton進行過濾
0
A
回答
2
遍歷你DGV行和檢查,如果第一個單元格的值=值(存款/取款/兩者取決於哪個單選按鈕被選中),然後設置
DataGridView1.Rows[rowIndex].Visible = false;
0
你可以根據所選的單選按鈕更改您的DataSource
。
BindingSource bs = new BindingSource();
grid.DataSource = bs;
通過改變你的單選按鈕選擇
bs.DataSource = q;
bs.ResetBindings(false);
對於Q使用:
var q = Transactions
var q = Transactions.Where(t=>t.TransactionType==Deposit)
var q = Transactions.Where(t=>t.TransactionType==Withdrawal)
0
,你想要做什麼看起來像這樣的代碼:(可能是不正確的變量名)
-
哪個單選按鈕被選中
- 校驗值
- 根據哪一個被選中,讀取列」每行的「transactionType」,
- 渲染可見或不是你想要的行。
Foreach(DataGridViewRow row in DataGridView.Rows)
{
if(radioButtonDeposit.isChecked())
{
if(row["TransactionType"].Value == Enum.Deposit)
{
row.Visible = true;
}
else
{
row.Visible = false;
}
}
else if(radioButtonWithdrawal.isChecked())
{
if(row["TransactionType"].Value == Enum.Withdrawal)
{
row.Visible = true;
}
else
{
row.Visible = false;
}
}
else
row.Visible = true;
}
相關問題
- 1. 使用INotifyPropertyChanged在Windows窗體中進行RadioButton綁定?
- 2. 使用c#&windows窗體進行XML序列化
- 3. 在C#中使用Windows窗體進行批量打印#
- 4. C# - 使用DataView進行過濾
- 5. 如何使用pcap.h進行過濾C++
- 6. Windows窗體RadioButton列表 - 綁定Enum屬性到RadioButton
- 7. 創建一個捕獲選定RadioButton的事件 - 使用C#Windows窗體
- 8. Windows窗體C#
- 9. c#windows窗體
- 10. 使用numpy.genfromtxt進行過濾
- 11. 使用Fiddler進行過濾
- 12. 使用組合框過濾子窗體
- 13. Rails 4:使用窗體過濾數據
- 14. 使用vba過濾MS Access子窗體
- 15. 使用linkchildfield過濾子窗體?
- 16. 使用C#Windows窗體應用程序
- 17. 阻止用戶使用Windows窗體 - c#
- 18. C#Windows窗體:關閉時[進程]
- 19. 用C#設置Windows窗體#
- 20. 使用acCmdFilterMenu進行過濾時獲取子窗體的記錄數
- 21. Windows窗體combobox.SelectedItem,C#
- 22. 在Windows窗體C#
- 23. 使用C#Windows窗體管理代碼
- 24. 使用C#的Windows窗體中的DataGridView
- 25. 想要使用Windows窗體C#
- 26. 的NullReferenceException是unhandles使用Windows窗體C#
- 27. c#asp.net使用Windows窗體WebBrowser
- 28. 在C#中使用Windows窗體創建多個窗體?
- 29. 使用Windows窗體在c#中進行泡泡排序。新手們問
- 30. 是否有可能使用Windows窗體C#對文件進行CRC校驗?#