In my grid, I want to limit the available filter conditions as they don't apply. I am doing so in the ContextMenuOpening event:
This works correctly. However, note that I am removing the first default item "Contains". Even though it is removed, it is the default condition selected:
http://screencast.com/t/vFv78ZoLE
This shows that the items have been removed correctly:
http://screencast.com/t/tcotptFmN4aK
Ideally I would like either No filter or Equals selected by default instead of Contains.
In addition, I'd like this functionality to be different for different columns. I'm trying to find how to determine which column is applicable in the code above, but am not able to find the needed info. I've also tried to subscribe to the CurrentColumnChanged, ColumnIndexChanged, and ColumnIndexChanging event to stored the selected column but it appears those events do not fire when I click on the filter button.
Private
Sub
WorkLogGridView_ContextMenuOpening(sender
As
Object
, e
As
ContextMenuOpeningEventArgs)
Handles
WorkLogGridView.ContextMenuOpening
If
e.ContextMenuProvider IsNot
Nothing
Then
e.ContextMenu.Items.Remove(e.ContextMenu.Items.
Single
(
Function
(item) item.Text =
"Contains"
))
e.ContextMenu.Items.Remove(e.ContextMenu.Items.
Single
(
Function
(item) item.Text =
"Does not contain"
))
e.ContextMenu.Items.Remove(e.ContextMenu.Items.
Single
(
Function
(item) item.Text =
"Starts with"
))
e.ContextMenu.Items.Remove(e.ContextMenu.Items.
Single
(
Function
(item) item.Text =
"Ends with"
))
e.ContextMenu.Items.Remove(e.ContextMenu.Items.
Single
(
Function
(item) item.Text =
"Is null"
))
e.ContextMenu.Items.Remove(e.ContextMenu.Items.
Single
(
Function
(item) item.Text =
"Is not null"
))
e.ContextMenu.Items.Remove(e.ContextMenu.Items.
Single
(
Function
(item) item.Text =
"Custom"
))
End
If
End
Sub
This works correctly. However, note that I am removing the first default item "Contains". Even though it is removed, it is the default condition selected:
http://screencast.com/t/vFv78ZoLE
This shows that the items have been removed correctly:
http://screencast.com/t/tcotptFmN4aK
Ideally I would like either No filter or Equals selected by default instead of Contains.
In addition, I'd like this functionality to be different for different columns. I'm trying to find how to determine which column is applicable in the code above, but am not able to find the needed info. I've also tried to subscribe to the CurrentColumnChanged, ColumnIndexChanged, and ColumnIndexChanging event to stored the selected column but it appears those events do not fire when I click on the filter button.