private void UpdateHighlightGrid(HashSet <int> dataGridViewMatchingRows) { if (dataGridView == null) { return; } if (dataGridViewHighlight == null) { return; } if (dataGridViewMatchingRows == null || dataGridViewMatchingRows.Count <= 0) { return; } if (!dataGridView.Parent.Controls.Contains(dataGridViewHighlight)) { dataGridView.Parent.Controls.Add(dataGridViewHighlight); } dataGridViewHighlight.AutoSizeRowsMode = dataGridView.AutoSizeRowsMode; dataGridViewHighlight.AutoSizeColumnsMode = dataGridView.AutoSizeColumnsMode; dataGridViewHighlight.Location = dataGridView.Location; dataGridViewHighlight.Size = dataGridView.Size; dataGridViewHighlight.BringToFront(); dataGridViewHighlight.Columns.Clear(); dataGridViewHighlight.Visible = true; foreach (DataGridViewColumn item in dataGridView.Columns) { if (item == null) { continue; } DataGridViewColumn column1 = item.Clone() as DataGridViewColumn; if (column1 == null) { continue; } dataGridViewHighlight.Columns.Add(column1); } dataGridViewHighlight.Rows.Clear(); foreach (int index in dataGridViewMatchingRows) { DataGridViewRow row = dataGridView.Rows[index]; if (row == null) { continue; } DataGridViewRow row1 = row.Clone() as DataGridViewRow; if (row1 == null) { continue; } List <object> objects = new List <object>(); foreach (DataGridViewCell oldCell in row.Cells) { objects.Add(oldCell.Value); } row1.SetValues(objects.ToArray <object>()); dataGridViewHighlight.Rows.Add(row1); } }
public void dodavanjeRobe() { dataGridEditovanje.ColumnCount = 4; dataGridEditovanje.Columns[0].Name = "Sifra Robe"; dataGridEditovanje.Columns[1].Name = "Kolicina robe"; dataGridEditovanje.Columns[2].Name = "Nova cena robe"; dataGridEditovanje.Columns[3].Name = "Ukupna cena robe na Otpremnici"; var listaRobeUProduktima = service.listaRobePordukata(otpremnicaIEdit.Id); var svaRoba = service.SifarnikRobeList(); for (int i = 0; i < listaRobeUProduktima.Count(); i++) { DataGridViewComboBoxCell CellSample = new DataGridViewComboBoxCell(); DataGridViewRow RowSample = new DataGridViewRow(); CellSample.DataSource = svaRoba; CellSample.DisplayMember = "SifraRobe"; CellSample.ValueMember = "Id"; CellSample.Value = listaRobeUProduktima[i].SifarnikRobeId; RowSample.Cells.Add(CellSample); dataGridEditovanje.Rows.Add(RowSample); dataGridEditovanje.Rows[i].Cells[1].Value = listaRobeUProduktima[i].KolicinaRobe; dataGridEditovanje.Rows[i].Cells[2].Value = listaRobeUProduktima[i].NovaCenaRobe; dataGridEditovanje.Rows[i].Cells[3].Value = listaRobeUProduktima[i].UkupnaCenaRobe; if (i == listaRobeUProduktima.Count() - 1) { dataGridEditovanje.Rows.Add((DataGridViewRow)RowSample.Clone()); } } }
public void Clone() { DataGridView dgv = new DataGridView(); dgv.Columns.Add("Column 1", "Column 1"); dgv.Columns.Add("Column 2", "Column 2"); dgv.Rows.Add("Cell 1", "Cell 2"); DataGridViewRow row1 = dgv.Rows[0]; row1.ErrorText = "Yikes!"; row1.Tag = "Helo"; row1.ReadOnly = true; row1.Visible = false; DataGridViewRow row2 = (DataGridViewRow)row1.Clone(); Assert.AreEqual(2, row2.Cells.Count, "A1"); Assert.AreEqual(null, row2.DataGridView, "A3"); Assert.AreEqual("Yikes!", row2.ErrorText, "A4"); Assert.AreEqual(-1, row2.HeaderCell.RowIndex, "A5"); Assert.AreEqual(-1, row2.Index, "A6"); Assert.AreEqual(true, row2.ReadOnly, "A7"); Assert.AreEqual("Helo", row2.Tag, "A8"); Assert.AreEqual(false, row2.Visible, "A9"); }
private DataGridViewRow[] CopyOfDataGridRows(DataGridView sourceGrid) { if (sourceGrid.Rows.Count == 0) { return(null); } int numberOfCells = sourceGrid.Columns.Count; int originalRowCount = sourceGrid.Rows.Count; DataGridViewRow[] backup = new DataGridViewRow[originalRowCount]; for (int i = 0; i < originalRowCount; i++) { DataGridViewRow row = sourceGrid.Rows[i]; DataGridViewRow clone = row.Clone() as DataGridViewRow; for (int cellIndex = 0; cellIndex < numberOfCells; cellIndex++) { clone.Cells[cellIndex].Value = row.Cells[cellIndex].Value; } backup[i] = clone; } return(backup); }
private void AddRowToDgv(string nom, string attribut) { DataGridViewRow row = (DataGridViewRow)rowClone.Clone(); row.Cells[0].Value = nom; row.Cells[1].Value = attribut; listJdtg.Rows.Add(row); }
private void AddRowToDgv(string nom, string prenom, string idJoueur) { DataGridViewRow row = (DataGridViewRow)rowClone.Clone(); row.Cells[0].Value = nom; row.Cells[1].Value = prenom; row.Cells[2].Value = idJoueur; jListDtg.Rows.Add(row); }
protected DataGridViewRow CloneRow(DataGridViewRow row) { DataGridViewRow newRow = row.Clone() as DataGridViewRow; newRow.Cells[0].Value = new Bitmap(row.Cells[0].Value as Bitmap); newRow.Cells[1].Value = string.Copy(row.Cells[1].Value as String); return(newRow); }
public static void CloneRowWithValues(this DataGridViewRow SingleRow, DataGridView Target) { DataGridViewRow Results = (DataGridViewRow)SingleRow.Clone(); for (Int32 Row = 0; Row < SingleRow.Cells.Count; Row++) { Results.Cells[Row].Value = SingleRow.Cells[Row].Value; } Target.Rows.Add(Results); }
public static DataGridViewRow CloneWithValues(this DataGridViewRow row) { DataGridViewRow clonedRow = (DataGridViewRow)row.Clone(); for (Int32 index = 0; index < row.Cells.Count; index++) { clonedRow.Cells[index].Value = row.Cells[index].Value; } return(clonedRow); }
private static DataGridViewRow CloneRow(DataGridViewRow row) { var clone = (DataGridViewRow)row.Clone(); for (int i = 0; i < row.Cells.Count; i++) { clone.Cells[i].Value = row.Cells[i].Value; } return(clone); }
/// <summary> /// 复制一个行数据 /// </summary> /// <param name="myCopyedDataGridViewRow"> </param> /// <returns> </returns> public DataGridViewRow CopyDataGriViewRow(DataGridViewRow myCopyedDataGridViewRow) { DataGridViewRow myNewDataGridViewRow = myCopyedDataGridViewRow.Clone() as DataGridViewRow; for (int i = 0; i < myCopyedDataGridViewRow.Cells.Count; i++) { myNewDataGridViewRow.Cells[i].Value = myCopyedDataGridViewRow.Cells[i].Value; } return(myNewDataGridViewRow); }
/// <summary> /// Копировать строку из таблицы /// </summary> /// <param name="row">строка</param> /// <returns></returns> internal override DataGridViewRow CloneWithValues(DataGridViewRow row) { DataGridViewRow clonedRow = (DataGridViewRow)row.Clone(); for (Int32 index = 0; index < row.Cells.Count; index++) { clonedRow.Cells[index].Value = row.Cells[index].Value; } return(clonedRow); }
public DataGridViewRow CloneWithValues(DataGridViewRow row) { DataGridViewRow clonedRow = (DataGridViewRow)row.Clone(); for (int i = 0; i < row.Cells.Count; i++) { clonedRow.Cells[i].Value = row.Cells[i].Value; clonedRow.Cells[i].Tag = row.Cells[i].EditedFormattedValue; } return(clonedRow); }
public DataGridViewRow CloneWithValues(DataGridViewRow row) { DataGridViewRow clonedRow = (DataGridViewRow)row.Clone(); //index starts at 2 to avoid copying the buy/return and qty columns for (Int32 i = 2; i < row.Cells.Count; i++) { clonedRow.Cells[i].Value = row.Cells[i].Value; } return(clonedRow); }
public DataGridViewRow CloneRowWithValues(DataGridViewRow SingleRow) { DataGridViewRow Results = (DataGridViewRow)SingleRow.Clone(); for (Int32 Row = 0; Row < SingleRow.Cells.Count; Row++) { Results.Cells[Row].Value = SingleRow.Cells[Row].Value; } return(Results); }
public ChangeSet(DataGridViewRow row, ChangeAction action, int index = -2) { this.Row = (DataGridViewRow)row.Clone(); for (int i = 0; i < row.Cells.Count; i++) { this.Row.Cells[i].Value = row.Cells[i].Value; } this.Index = (index == -2 ? row.Index : index); this.Action = action; }
private void AddRowToDgv(string titre, string description, string idPartie, bool isMj, int idJoueur) { DataGridViewRow rowClone = (DataGridViewRow)row.Clone(); rowClone.Cells[0].Value = titre; rowClone.Cells[1].Value = description; rowClone.Cells[2].Value = idPartie; rowClone.Cells[3].Value = isMj; rowClone.Cells[4].Value = idJoueur; dgvParties.Rows.Add(rowClone); }
private void copyToolStripMenuItem_Click(object sender, EventArgs e) { DataGridViewRow rowToCopy = gridViewLichCB.SelectedRows[0]; duplicate = (DataGridViewRow)rowToCopy.Clone(); for (int i = 0; i < 9; i++) { duplicate.Cells[i].Value = rowToCopy.Cells[i].Value; } lblUpdateStatus.ForeColor = ChangeLogColor; lblUpdateStatus.Text = "Đã sao chép hàng " + (rowToCopy.Index + 1).ToString() + " (MACB = '" + rowToCopy.Cells[0].Value.ToString() + "')."; }
public DataGridViewRow CloneWithValues(DataGridViewRow row) { var clonedRow = (DataGridViewRow)row.Clone(); for (var index = 0; index < row.Cells.Count; index++) { if (clonedRow != null) { clonedRow.Cells[index].Value = row.Cells[index].Value; } } return(clonedRow); }
private void copyRowToolStripMenuItem_Click(object sender, EventArgs e) { DataGridViewRow rowToCopy = dataGridView1.CurrentCell.OwningRow; rowToCopy.Selected = true; QuanLy.duplicate = (DataGridViewRow)rowToCopy.Clone(); for (int i = 0; i < 9; i++) { QuanLy.duplicate.Cells[i].Value = rowToCopy.Cells[i].Value; } lblUpdateStatus.ForeColor = QuanLy.ChangeLogColor; lblUpdateStatus.Text = "Đã sao chép hàng " + (rowToCopy.Index + 1).ToString() + " (MACB = '" + rowToCopy.Cells[0].Value.ToString() + "')."; }
private void bt_agregar_Click(object sender, EventArgs e) { if (dataGrid_voluntarios.SelectedRows.Count == 1) { DataGridViewRow dr = dataGrid_voluntarios.Rows[dataGrid_voluntarios.CurrentCell.RowIndex]; DataGridViewRow data = (DataGridViewRow)dr.Clone(); data.Cells[0].Value = dr.Cells[0].Value; data.Cells[1].Value = dr.Cells[1].Value; data.Cells[2].Value = dr.Cells[2].Value; dataGrid_voluntariosProg.Rows.Add(data); dataGrid_voluntarios.Rows.RemoveAt(dataGrid_voluntarios.CurrentRow.Index); dataGrid_voluntariosProg.Sort(dataGrid_voluntariosProg.Columns["Id_persona"], ListSortDirection.Ascending); } }
//Move Up Button private void button4_Click(object sender, EventArgs e) { DataGridViewRow CurrentRow = dataGridView1.CurrentRow; DataGridViewRow Results = (DataGridViewRow)(CurrentRow.Clone()); Int32 currentIndex = dataGridView1.CurrentRow.Index; dataGridView1.Rows.RemoveAt(currentIndex); Int32 NewIndex = System.Convert.ToInt32(((currentIndex == 0) ? 0 : currentIndex - 1)); for (Int32 Row = 0; Row < CurrentRow.Cells.Count; Row++) { Results.Cells[Row].Value = CurrentRow.Cells[Row].Value; } dataGridView1.Rows.Insert(NewIndex, Results); }
private void btnDown_Click(object sender, EventArgs e) { if (dgvData.SelectedRows.Count <= 0) { MessageBox.Show("请先选择一行记录。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } DataGridViewRow dgvr = dgvData.SelectedRows[0]; int index = dgvr.Index; if (index == dgvData.Rows.Count - 1) { MessageBox.Show("选中行己经是最后一行了。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } DataGridViewRow newDgvr = (DataGridViewRow)dgvr.Clone(); for (int i = 0; i < dgvr.Cells.Count; i++) { newDgvr.Cells[i].Value = dgvr.Cells[i].Value; } dgvData.Rows.RemoveAt(index); dgvData.Rows.Insert(index + 1, newDgvr); dgvData.Rows[index + 1].Selected = true; int j = 0; foreach (DataGridViewRow dr in dgvData.Rows) { string strWhere = " CODE = " + "'" + dr.Cells["PRODUCTION_PROCESS_CODE"].Value.ToString() + "'"; DataSet ds = BProductionProcess.GetList(strWhere); decimal productioncycle = CConvert.ToDecimal(ds.Tables[0].Rows[0]["PRODUCTION_CYCLE"].ToString().Trim()); if (j != 0) { dr.Cells["START_DATE"].Value = CConvert.ToDateTime(dgvData.Rows[j - 1].Cells["END_DATE"].Value.ToString()); dr.Cells["END_DATE"].Value = CConvert.ToDateTime(dgvData.Rows[j].Cells["START_DATE"].Value.ToString()).AddDays(CConvert.ToDouble(productioncycle) + 0D); j++; } else { dr.Cells["START_DATE"].Value = txtSlipDateFrom.Text; dr.Cells["END_DATE"].Value = CConvert.ToDateTime(txtSlipDateFrom.Text).AddDays(CConvert.ToDouble(productioncycle) + 0D); j++; } } }
private void CopyDataGridView(DataGridView dgv_org, DataGridView dgv_new) { //Pour chaque rangéé du dgv original for (int i = 0; i < dgv_org.RowCount; i++) { //Clone la rangée DataGridViewRow row = dgv_org.Rows[i]; DataGridViewRow clonedRow = (DataGridViewRow)row.Clone(); for (Int32 index = 0; index < row.Cells.Count; index++) { clonedRow.Cells[index].Value = row.Cells[index].Value; //Copie la value de chaque cell } dgv_new.Rows.Add(clonedRow); //Ajoute la rangée cloné dans le nouveau dgv } DGV_Perso.ClearSelection(); }
void UpdateInfoMyTrades(IEnumerable <MyTrade> trades) { var list = Trader.Objects.tMyTrades.AsArray; foreach (var t in trades) { var row = (DataGridViewRow)RowMyTradeClone.Clone(); mutexMyTrade.WaitOne(); row.Cells[0].Value = ""; listRowsMyTrades.Add(row); row.Cells[0].Value = countMyTrades.ToString(); row.Cells[1].Value = t.Trade.Number.ToString(); row.Cells[2].Value = t.OrderNum.ToString(); row.Cells[3].Value = t.Trade.Sec.Code; row.Cells[4].Value = t.Trade.DateTrade.ToLongTimeString(); row.Cells[5].Value = t.Trade.Price.ToString(); row.Cells[6].Value = t.Trade.Volume.ToString(); row.Cells[7].Value = t.Trade.Direction == OrderDirection.Buy ? "Buy" : "Sell"; mutexMyTrade.ReleaseMutex(); countMyTrades++; } dataGridViewMyTrades.GuiAsync(() => { mutexMyTrade.WaitOne(); if (listRowsMyTrades.Count > 0) { dataGridViewMyTrades.Rows.AddRange(listRowsMyTrades.ToArray()); listRowsMyTrades.Clear(); if (ScrollMyTrades == null) { ScrollMyTrades = (VScrollBar)dataGridViewAllTrade.Controls[1]; } int v = ScrollMyTrades.Value; int maxScroll = ScrollMyTrades.Maximum; //if (v > maxScroll - 3000 && v != 0) //ScrollMyTrades.Value = ScrollMyTrades.Maximum; dataGridViewMyTrades.FirstDisplayedCell = dataGridViewMyTrades.Rows[dataGridViewMyTrades.Rows.Count - 1].Cells[0]; } mutexMyTrade.ReleaseMutex(); }); }
//Changes the current cross section private void listBoxCrossSecs_SelectedIndexChanged(object sender, EventArgs e) { if (listBoxCrossSecs.SelectedIndex != -1) { _projectPlugIn.CurrentBeam = _projectPlugIn.Beams[listBoxCrossSecs.SelectedIndex]; _projectPlugIn.SelectedBeamIndex = listBoxCrossSecs.SelectedIndex; if (_projectPlugIn.CurrentBeam.CrossSec is PredefinedCrossSection) { //Update dataGridviewRows DataGridViewRow r = (DataGridViewRow)dataGridViewLoads.Rows[0].Clone(); dataGridViewLoads.Rows.Clear(); int i = 0; foreach (LoadCase lc in _projectPlugIn.CurrentBeam.LoadCases) { if (lc.GetType() == typeof(ColLoadCase)) { ColLoadCase clc = (ColLoadCase)lc; r = (DataGridViewRow)r.Clone(); double NormalForce = dataGridViewLoads.Rows.Add(r); dataGridViewLoads.Rows[i].Cells[0].Value = clc.Name; dataGridViewLoads.Rows[i].Cells[1].Value = clc.N_Ed * Math.Pow(10, -3); dataGridViewLoads.Rows[i].Cells[2].Value = clc.M_EzTop * Math.Pow(10, -3); dataGridViewLoads.Rows[i].Cells[3].Value = clc.M_EzBottom * Math.Pow(10, -3); dataGridViewLoads.Rows[i].Cells[4].Value = clc.M_EyTop * Math.Pow(10, -3); dataGridViewLoads.Rows[i].Cells[5].Value = clc.M_EyBottom * Math.Pow(10, -3); i++; } } UpdatePredefinedFromCrossSection(); EnablePredefinedCrossSection(); } else { UpdateValuesGenericCrossSection(); EnableGenericCrossSection(); } ZoomToCurrentBeam(); } }
//agrega las filas recibidas. rows_data contiene elementos tipo arraylist public void agregarFilas(ArrayList rows_data) { DataGridViewRow r = (DataGridViewRow)this.Rows[0].Clone(); this.Rows.Clear(); IEnumerator ie_data = rows_data.GetEnumerator(); while (ie_data.MoveNext()) { ArrayList tmp = (ArrayList)ie_data.Current; IEnumerator ietmp = tmp.GetEnumerator(); int indice = 0; while (ietmp.MoveNext()) { r.Cells[indice].Value = ietmp.Current; indice++; } DataGridViewRow r2 = (DataGridViewRow)r.Clone(); this.Rows.Add(r2); } }
public IEnumerable <DataGridViewRow> BuildTableRows(DataGridViewRow clonableRow) { BuildSymbolTable(); using (var sr = new StreamReader(FileName)) { string line = sr.ReadLine(); int counter = 0; while ((line = sr.ReadLine()) != null) { var instructionArray = line.Split(','); if (instructionArray[1] == "ORG") { counter = int.Parse(instructionArray[2], System.Globalization.NumberStyles.HexNumber); } else { Opcode opcode; string operand = instructionArray[2]; Enum.TryParse <Opcode>(instructionArray[1].ToUpper(), out opcode); // Build Row var row = (DataGridViewRow)clonableRow.Clone(); var hex = buildHexValue(opcode, operand); row.Cells[0].Value = counter.ToString("X3"); row.Cells[1].Value = instructionArray[0]; row.Cells[2].Value = opcode.ToString(); row.Cells[3].Value = operand; row.Cells[4].Value = hex; memoryTable[counter] = int.Parse(hex, System.Globalization.NumberStyles.HexNumber); yield return(row); counter++; } } } }
private void Copy() { DataGridViewRow row = GetSelectedRowFromCell(gridJobs); if (row == null) { return; } DataGridViewRow copy = (DataGridViewRow)row.Clone(); for (int i = 0; i < row.Cells.Count; i++) { copy.Cells[i].Value = row.Cells[i].Value; } copy.Cells[0].Value = "Copy Of " + copy.Cells[0].Value.ToString(); gridJobs.Rows.Add(copy); foreach (DataGridViewRow grow in gridJobs.Rows) { grow.Selected = false; } copy.Selected = true; SaveJob(gridJobs, copy.Index); }
private void getEntriesForKey(string keyToSearch) { Key key = new Key(keyToSearch); foreach (Entry value in key.getEntries()) { updateEntryAmountIfNecessary(); if (value.Valid) { bool alreadyExists = false; foreach (DataGridViewRow row in entriesList) { if (row.Cells[4].Value != null) { string existingPath = row.Cells[4].Value.ToString(); if (value.Path == existingPath) { alreadyExists = true; break; } } } if (!alreadyExists) { DataGridViewRow newEntry = (DataGridViewRow)baseRow.Clone(); newEntry.Cells[0].Value = value.Name; newEntry.Cells[1].Value = value.Exists; newEntry.Cells[2].Value = value.Exists == true ? value.Creation : (DateTime?)null; newEntry.Cells[3].Value = value.Exists == true ? value.Modification : (DateTime?)null; newEntry.Cells[4].Value = value.Path; entryAmount++; entriesList.Add(newEntry); } } } }