【问题标题】:Filter DataGridView based on ComboBox selection [duplicate]根据 ComboBox 选择过滤 DataGridView [重复]
【发布时间】:2016-05-20 08:58:57
【问题描述】:

这是我DataGridView 上的视图。我想根据ComboBox 中的选择过滤环境。数据已从 xml 填充

【问题讨论】:

    标签: c# winforms datagridview


    【解决方案1】:

    你需要:

    1) 手动填充组合框,首先添加“All”,然后添加来自 IndustryGroupsDataSet.Tables[0] 的项目。

    2) 在 CompaniesDataSet.Tables[0] 和 dataGridView1.DataSource 之间添加一个 BindingSource。

    3) 在组合框的 SelectedIndexChanged 事件中,更改 BindingSource 的 Filter 属性。如果所选索引为零(“All”),则将 Filter 设置为 null,否则将 filter 设置为 String.Format("groupID = '{0}'", cmbBxGroupFilter.SelectedValue)。

    从这里获得: https://social.msdn.microsoft.com/Forums/windows/en-US/de807368-afa0-4bfe-bc8f-7c52746d60c9/filter-datagridview-based-on-combo-box-selection?forum=winforms

    【讨论】:

      猜你喜欢
      • 2018-08-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-11
      • 1970-01-01
      • 2012-10-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多