111,098
社区成员




public class City:INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(string propertyName)
{
if (this.PropertyChanged != null)
{
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
public int ID{get;set;}
private string _address = string.Empty;
public string Address
{
get
{
return _address;
}
set
{
if (value != this._address)
{
_address = value;
NotifyPropertyChanged("Address");
}
}
}
public override bool Equals(object obj)
{
if ((obj as City).ID.Equals(this.ID))
return true;
return false;
}
public override int GetHashCode()
{
return (typeof(City).ToString() + this.ID).GetHashCode();
}
}
private BindingList<City> cityList = new BindingList<City>();
public void Add(Country c)
{
//这里将Country 转换为 City
cityList.Add(city);
}
public void Remove(Country c)
{
City city = cityList.Where((_c)=> _c.ID == c.ID ).First();
cityList.Remove(city);
}
System.ArgumentOutOfRangeException: 提供的行索引超出范围。
参数名: rowIndex
在 System.Windows.Forms.DataGridViewRowCollection.GetRowState(Int32 rowIndex)
在 System.Windows.Forms.DataGridView.OnRowGlobalAutoSize(Int32 rowIndex)
在 System.Windows.Forms.DataGridView.OnRowHeightChanged(DataGridViewRowEventArgs e)
在 System.Windows.Forms.DataGridView.OnBandThicknessChanged(DataGridViewBand dataGridViewBand)
在 System.Windows.Forms.DataGridViewBand.set_ThicknessInternal(Int32 value)
在 System.Windows.Forms.DataGridView.OnRemovedRow_PostNotification(DataGridViewRow dataGridViewRow, Point newCurrentCell)
在 System.Windows.Forms.DataGridViewRowCollection.OnCollectionChanged_PostNotification(CollectionChangeAction cca, Int32 rowIndex, Int32 rowCount, DataGridViewRow dataGridViewRow, Boolean changeIsDeletion, Boolean changeIsInsertion, Boolean recreateNewRow, Point newCurrentCell)
在 System.Windows.Forms.DataGridViewRowCollection.OnCollectionChanged(CollectionChangeEventArgs e, Int32 rowIndex, Int32 rowCount, Boolean changeIsDeletion, Boolean changeIsInsertion, Boolean recreateNewRow, Point newCurrentCell)
在 System.Windows.Forms.DataGridViewRowCollection.RemoveAtInternal(Int32 index, Boolean force)
在 System.Windows.Forms.DataGridView.DataGridViewDataConnection.ProcessListChanged(ListChangedEventArgs e)
在 System.Windows.Forms.DataGridView.DataGridViewDataConnection.currencyManager_ListChanged(Object sender, ListChangedEventArgs e)
在 System.Windows.Forms.CurrencyManager.OnListChanged(ListChangedEventArgs e)
在 System.Windows.Forms.CurrencyManager.List_ListChanged(Object sender, ListChangedEventArgs e)
在 System.ComponentModel.BindingList`1.OnListChanged(ListChangedEventArgs e)
在 System.ComponentModel.BindingList`1.FireListChanged(ListChangedType type, Int32 index)
在 System.ComponentModel.BindingList`1.RemoveItem(Int32 index)
在 System.Collections.ObjectModel.Collection`1.Remove(T item)