I know this seems rather simple, and that's what I thought too, but it actually isn't. I have a GridView, with SelectionMode="Single", and I want to simply unselect a selected item by clicking on it. Problem is, SelectionChanged doesn't fire when you select an item that is already selected. I've tried having an int equal to the GridView's SelectedIndex on each SelectionChanged, and then check on Grid_Tapped to see if PreviousSelectedIndex == CurrentlySelectedIndex, but the SelectionChanged event fires nanoseconds before the Grid_Tapped, so it doesn't work. Any ideas?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
Use the
CellClick
event.In example,
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
,e.RowIndex
holds the index of the cell that was clicked. All you have to do is check if this index is equal toSelectedIndex
.I think instead of Delay its better to use this:
Yes it is a bit weird default behavior, you can do the following trick to solve that (there are many ways)
1.- the XAML
2.- The event code:
If you do not wait a bit, the internals events keep the selected item, with that way it is solved and the SelectedItem is Deselected.