Hi there,

I've been messing with the DataGridView component and it's really quite cool what you can do with it. I have it working for the most part, apart from one thing. I can't seem to get filtering working. The code I have is fort testing purposes only, basically just to get to know how to work with the DGV. I did notice that bSource.SupportsFiltering was set to False and I have no idea how to change that.

vb Code:
  1. Private Sub Dialog1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2.         Dim bList As New System.ComponentModel.BindingList(Of ListItem)
  3.         Dim bSource As New BindingSource()
  4.  
  5.         bSource.DataSource = bList
  6.  
  7.         ' ListItem has Name, ID and Important properties, which are String, Integer and Boolean
  8.         ' respectively.
  9.  
  10.         bList.Add(New ListItem("Item 1", 1, True))
  11.         bList.Add(New ListItem("Item 2", 2, False))
  12.         bList.Add(New ListItem("Item 3", 3, True))
  13.         bList.Add(New ListItem("Item 4", 4, False))
  14.  
  15.         DataGridView1.DataSource = bSource
  16.  
  17.         DataGridView1.ColumnHeadersVisible = False
  18.  
  19.         ' This makes sure that only 'Important' and 'Name' are shown and displayed
  20.         ' in the correct order
  21.         DataGridView1.Columns(2).DisplayIndex = 0
  22.         DataGridView1.Columns(1).DisplayIndex = 1
  23.         DataGridView1.Columns(0).DisplayIndex = 2
  24.         DataGridView1.Columns(0).Visible = False
  25.  
  26.         DataGridView1.Columns(2).Width = 20
  27.         DataGridView1.Columns(1).AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
  28.         DataGridView1.GridColor = Color.White
  29.         DataGridView1.RowHeadersVisible = False
  30.         DataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect
  31.  
  32.  
  33.     End Sub
  34.  
  35.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  36.         Dim bSource As BindingSource = DataGridView1.DataSource
  37.         bSource.Filter = "ID == 2"
  38.         DataGridView1.Refresh()
  39.     End Sub

Basically, to test the filter, I wanted to press a button and then apply the filter. I am sure that once I get the hang of the filtering, I can implement it fully in my main app.

Gr,
Mightor