本文介绍了如何使用4 ComboBox过滤DataGridView中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有包含一些细节的DataGridView,我想使用4来过滤这些数据 ComboBoxes。 全心全意付款 我很抱歉因为我的英语不好 这是一个例子 www.gulfup/?kWMojY [ ^ ]
I have DataGridView that Contains Some Details , I want filter these Data using 4 ComboBoxes . Thanks For All I'M Sorry Because My Poor English This Is An Example www.gulfup/?kWMojY[^]
推荐答案这成为一个设计问题。我发现最好有4个组合和一个应用过滤的按钮。在按钮的单击事件中,您根据组合框的选定项将过滤应用于基础数据集。 该按钮允许用户从中进行选择每个组合然后应用过滤器。如果您使用组合的更改事件,则仅基于当前组合过早地应用过滤! This becomes a design issue. I find that it is best to have the 4 combos and a button that applies the filtering. In the click event of the button you apply the filtering to the underlying data collection based on the selected items of the combo boxes. The button allows the user to select from each combo and then apply the filter. If you use the change event of the combo's the filtering is prematurely applied based on only the current combo!
如果您想在每次用户更改组合框选择时进行过滤,则需要: 为OnChangeEvent的每个组合框添加一个事件处理程序(在属性窗口中更改为事件视图,然后双击OnChange) 在每个事件处理程序中: 从组合框中获取所选值 过滤填充datagridview的集合 注意您可能需要更新DGV的绑定。 您真的需要尝试自己帮助! If you want to do the filtering every time a user changes a combobox selection you need to: Add an event handler to each combobox for the OnChangeEvent (change to the event view in the properties window and double click on the OnChange) In each event handler: Get the selected value from the combobox Filter the collection populating the datagridview Note you may need to update the binding of the DGV. You really need to try and help yourself!
没有人可以帮助我, 有人帮助我 No one can help me , Some one help me
更多推荐
如何使用4 ComboBox过滤DataGridView中的数据
发布评论