private void dg_ItemsSourceChanged(object sender, EventArgs e) { if (!settingUp) { scen.PersonRelationIds.Clear(); foreach (DataRow dr in dt.Rows) { PersonIDRelation personIDRelation = new PersonIDRelation(); personIDRelation.PersonID1 = (int)dr["ID"]; personIDRelation.PersonID2 = (int)dr["对方武将ID"]; personIDRelation.Relation = (int)dr["与对方武将的友好度"]; scen.PersonRelationIds.Add(personIDRelation); } initdt(); } MainWindow.pasting = false; }
private void Dt_RowChanged(object sender, DataRowChangeEventArgs e) { try { if (!settingUp && !MainWindow.pasting) { scen.PersonRelationIds.Clear(); foreach (DataRow dr in dt.Rows) { PersonIDRelation personIDRelation = new PersonIDRelation(); personIDRelation.PersonID1 = (int)dr["ID"]; personIDRelation.PersonID2 = (int)dr["对方武将ID"]; personIDRelation.Relation = (int)dr["与对方武将的友好度"]; scen.PersonRelationIds.Add(personIDRelation); } initdt(); } } catch (Exception ex) { MessageBox.Show("資料輸入錯誤。" + ex.Message); } }