private void listView1_SelectedIndexChanged(object sender, EventArgs e) { if (internalchg) { return; } if (selectedResource != null) { ResourceChangingEventArgs rcea = new ResourceChangingEventArgs(selectedResource); OnSelectedResourceChanging(this, rcea); if (rcea.Cancel) { internalchg = true; listView1.SelectedItems.Clear(); listView1.SelectedIndices.Add(listView1.Items.IndexOf(selectedResource)); listView1.SelectedItems[0].EnsureVisible(); internalchg = false; return; } } selectedResource = (listView1.SelectedItems.Count == 1) ? listView1.SelectedItems[0] : null; OnSelectedResourceChanged(this, new ResourceChangedEventArgs(selectedResource)); }
protected virtual void OnSelectedResourceChanging(object sender, ResourceChangingEventArgs e) { if (SelectedResourceChanging != null) { SelectedResourceChanging(sender, e); } }
private void listView1_SelectedIndexChanged(object sender, EventArgs e) { if (internalchg) return; if (selectedResource != null) { ResourceChangingEventArgs rcea = new ResourceChangingEventArgs(selectedResource); OnSelectedResourceChanging(this, rcea); if (rcea.Cancel) { internalchg = true; listView1.SelectedItems.Clear(); listView1.SelectedIndices.Add(listView1.Items.IndexOf(selectedResource)); listView1.SelectedItems[0].EnsureVisible(); internalchg = false; return; } } selectedResource = (listView1.SelectedItems.Count == 1) ? listView1.SelectedItems[0] : null; OnSelectedResourceChanged(this, new ResourceChangedEventArgs(selectedResource)); }
protected virtual void OnSelectedResourceChanging(object sender, ResourceChangingEventArgs e) { if (SelectedResourceChanging != null) SelectedResourceChanging(sender, e); }