/// <summary>Removes the row from the collection.</summary> /// <param name="dataGridViewRow">The row to remove from the <see cref="IDataGridViewRowCollection"></see>.</param> /// <exception cref="T:System.InvalidOperationException">The associated <see cref="IDataGridView"></see> control is performing one of the following actions that temporarily prevents new rows from being added:Selecting all cells in the control.Clearing the selection.-or-This method is being called from a handler for some events-or-dataGridViewRow is the row for new records.-or-The associated <see cref="IDataGridView"></see> control is bound to an <see cref="T:System.ComponentModel.IBindingList"></see> implementation with <see cref="P:System.ComponentModel.IBindingList.AllowRemove"></see> and <see cref="P:System.ComponentModel.IBindingList.SupportsChangeNotification"></see> property values that are not both true. </exception> /// <exception cref="T:System.ArgumentException">dataGridViewRow is not contained in this collection.-or-dataGridViewRow is a shared row.</exception> /// <exception cref="T:System.ArgumentNullException">dataGridViewRow is null.</exception> /// <filterpriority>1</filterpriority> public void Remove(IDataGridViewRow dataGridViewRow) { if (dataGridViewRow == null) { throw new ArgumentNullException("dataGridViewRow"); } _rows.RemoveAt(dataGridViewRow.Index); }
private void btnClearAll_Click(object sender, EventArgs e) { if (MessageBox.Show(this, "真的要清空此列表吗?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { try { while (true) { listref.RemoveAt(0); } } catch { } UpdateDisplay(); } }
/// <summary> /// Update the grid of the shared files. /// </summary> private void UpdateSharedFilesGrid() { if (this.InvokeRequired) { this.Invoke(new MethodInvoker(() => { this.UpdateSharedFilesGrid(); })); } else { DataGridViewRowCollection rows = this.SharedFilesGrid.Rows; bool updateAllOtherRows = false; int i = 0; for (int a = (rows.Count - 1); a > 0; a--, i++) { if (i < Lists.FilesList.Count) { try { if (updateAllOtherRows == true || rows[i].Cells[2].Value.ToString() != Lists.FilesList.List[i].SHA1) { rows[i].Cells[0].Value = Lists.FilesList.List[i].Name; rows[i].Cells[1].Value = Utilities.Converterer.AutoConvertSizeFromByte(Lists.FilesList.List[i].Size); rows[i].Cells[2].Value = Lists.FilesList.List[i].SHA1; rows[i].Cells[3].Value = Lists.FilesList.List[i].Path; // update all the other rows updateAllOtherRows = true; } } catch { } } else { // remove the extra rows for (int n = (rows.Count - 1) - i; n > 0; n--) { rows.RemoveAt(i); } break; } } // if necessary add new rows for (; i < Lists.FilesList.Count; i++) { rows.Add(Lists.FilesList.List[i].Name, Utilities.Converterer.AutoConvertSizeFromByte(Lists.FilesList.List[i].Size), Lists.FilesList.List[i].SHA1, Lists.FilesList.List[i].Path); } } }
public void RemoveOrganismo(IOrganismo o) { DataGridViewRowCollection Rows = GetRows("dataGridOrgs"); for (int i = 0; i < Rows.Count; i++) { IOrganismo or = (IOrganismo)Rows[i].Cells[0].Value; if (or != null && or.oid == o.oid) { Rows.RemoveAt(i); return; } } }
public static bool RemoveEndingItems(this DataGridViewRowCollection rows, int count) { if (rows.Count == count) { return(true); } bool result = false; for (int i = rows.Count - 2; i >= count; i--) { rows.RemoveAt(i); result &= true; } return(result); }
//删除功能属性 private void DeleteFunction_Click(object sender, EventArgs e) { try { DataGridViewRowCollection rows = this.dataGridView1.Rows; rows.RemoveAt(dataGridView1.CurrentRow.Index); index2--; Savemode = false; if (index2 == 0) { ModifyFunction.Enabled = false; DeleteFunction.Enabled = false; } } catch { MessageBox.Show("请选择要删除的属性!"); } }
private void RemovePiorTeste() { DataGridViewRowCollection Rows = frmPrincipal.GetRows("dataGridRuns"); MonteCarlo mc = Rows[0].Cells[0].Value as MonteCarlo; int piorIndex = 0; double piorResultado = mc.CalcFitness(); for (int i = 1; i < Rows.Count; i++) { mc = Rows[i].Cells[0].Value as MonteCarlo; if (mc != null) { double resultado = mc.CalcFitness(); if (resultado < piorResultado) { piorResultado = resultado; piorIndex = i; } } } Rows.RemoveAt(piorIndex); }