csharp_boy
Newcomer
- Joined
- Feb 5, 2006
- Messages
- 5
I've noticed that in .NET, the IndexChanged event runs after it changes the index, where as the ItemCheck event runs before it checks/unchecks the boxes.
Like for example, say I have a listview with 1 item in it, and I do this.
private void listView1_SelectedIndexChanged(object sender, System.EventArgs e)
{
Debug.Writeline(listView1.SelectedItems.Count);
}
When I select an item, it'll display 1 and when I unselect all items, it'll display 0.
On the other hand, if I do this, the reverse happens.
private void listView1_ItemCheck(object sender, System.Windows.Forms.ItemCheckEventArgs e)
{
Debug.WriteLine(listView1.CheckedItems.Count);
}
When I check an item, it'll still display 0 and when I uncheck the item, it'll display 1.
Is there any reason that Microsoft has implemented it like this?
Like for example, say I have a listview with 1 item in it, and I do this.
private void listView1_SelectedIndexChanged(object sender, System.EventArgs e)
{
Debug.Writeline(listView1.SelectedItems.Count);
}
When I select an item, it'll display 1 and when I unselect all items, it'll display 0.
On the other hand, if I do this, the reverse happens.
private void listView1_ItemCheck(object sender, System.Windows.Forms.ItemCheckEventArgs e)
{
Debug.WriteLine(listView1.CheckedItems.Count);
}
When I check an item, it'll still display 0 and when I uncheck the item, it'll display 1.
Is there any reason that Microsoft has implemented it like this?