/// <summary> /// 插入行 /// </summary> protected virtual void InsertRow <T>() where T : new() { if (FocusedRowHandle < 0) { return; } gvDataBindingSource.Insert(FocusedRowHandle, new T()); }
private void btnInsertBefore_Click(object sender, EventArgs e) { if (dgvStkInLine.CurrentRow != null) { STK_InLineResult rst = new STK_InLineResult(); InitNewData(rst); bsStkInLine.Insert(dgvStkInLine.CurrentRow.Index, rst); } }
private void InitPersons() { perbs.Add(new Person("Sok Dara", 28)); perbs.Add(new Person("Leng Map", 22)); //Inserting this lines after step 4 (creating class Student) perbs.Insert(1, new Student("Heng Meta", 23, 100)); perbs.Add(new Student("Heng Kakada", 18, 60)); //Inserting this lines after Step 5 (creting class Worker) perbs.Insert(2, new Worker("Um Neary", 35, 400, "ALIM.Co LTD")); perbs.Insert(3, new Worker("San Phanny", 27, 500, "KMS Ratical")); }
public static void Insert(this BindingSource aBindingSource, object aBindingSourseInsertingData) { int position = aBindingSource.Position; if (position == -1) { aBindingSource.Insert(aBindingSource.Count, aBindingSourseInsertingData); } else { aBindingSource.Insert(aBindingSource.Position, aBindingSourseInsertingData); } }
public void DoPaste() { var clipboardText = ClipboardHelper.GetClipboardText(this); if (clipboardText == null) { return; } using (var reader = new StringReader(clipboardText)) { string line; while (null != (line = reader.ReadLine())) { line = line.Trim(); if (string.IsNullOrEmpty(line)) { continue; } var color = RgbHexColor.ParseHtmlColor(line) ?? RgbHexColor.ParseRgb(line); if (color == null) { MessageDlg.Show(this, string.Format(Resources.EditCustomThemeDlg_DoPaste_Unable_to_parse_the_color___0____Use_HEX_or_RGB_format_, line)); return; } var colorRow = new T { Color = color.Value }; BindingSource.Insert(BindingSource.Position, colorRow); } } }
public static void MoveUp(this BindingSource aBindingSource) { int position = aBindingSource.Position; if (position == -1) { return; } if (position == 0) { return; // already at top } aBindingSource.RaiseListChangedEvents = false; object current = aBindingSource.Current; aBindingSource.Remove(current); position--; aBindingSource.Insert(position, current); aBindingSource.Position = position; aBindingSource.RaiseListChangedEvents = true; aBindingSource.ResetBindings(false); }
private void btnInsertBefore_Click(object sender, EventArgs e) { ORD_PurchaseReturnLineResult rst = new ORD_PurchaseReturnLineResult(); InitNewData(rst); bsPurchaseReturnLine.Insert(dgvPurchaseReturnLine.CurrentRow.Index, rst); }
public void DataInsert(PathData p) { listBox_myList.BeginUpdate(); myListSrc.Insert(0, p); listBox_myList.ClearSelected(); listBox_myList.SelectedIndex = 0; listBox_myList.EndUpdate(); }
protected virtual void InsertRow <T>(BindingSource bind, int rowHandle) where T : new() { if (rowHandle < 0) { return; } bind.Insert(rowHandle, new T()); }
private void up_Button_Click(object sender, EventArgs e) { int position = _bindingSource.Position; if (_bindingSource.Count > 1 && position > 0) { _bindingSource.RaiseListChangedEvents = false; object selected = _bindingSource.Current; _bindingSource.Remove(selected); position--; _bindingSource.Insert(position, selected); _bindingSource.Position = position; _bindingSource.RaiseListChangedEvents = true; _bindingSource.ResetBindings(false); } }
private void btnInsert_Click(object sender, EventArgs e) { int index = dgvFrequencyList.CurrentCell.RowIndex; frequencySource.Insert(index, 0.0f); dgvFrequencyList.CurrentCell = dgvFrequencyList[0, index]; dgvFrequencyList.BeginEdit(false); }
private void btnMoveUp_Click(object sender, EventArgs e) { try { var pos = _bs.Position; if (pos > 0) { var curr = _bs.Current; _bs.RemoveAt(pos); _bs.Insert(pos - 1, curr); _bs.Position = pos - 1; } } catch (Exception ex) { Utils.HandleError(ex); } }
internal void Expand(BindingSource bSource) { int index = bSource.IndexOf(this); foreach (AppointStateHistory item in this) { bSource.Insert(++index, item); } Expanded = true; }
void ListBox1DragDrop(object sender, DragEventArgs e) { int index = lbFileList.IndexFromPoint(lbFileList.PointToClient(new Point(e.X, e.Y))); FileItem drag_item = (FileItem)e.Data.GetData(typeof(FileItem)); if (index >= 0) { filesBinding.Remove(drag_item); filesBinding.Insert(index, drag_item); } }
private void bAddToOrder_Click(object sender, EventArgs e) { var p = items.First(x => x.ItemId == long.Parse(fiCbo.SelectedValue.ToString())); int q = (int)numericUpDown1.Value; decimal a = p.Price * q; OrderItemEnlarged item = new OrderItemEnlarged { ItemId = long.Parse(fiCbo.SelectedValue.ToString()), OrderId = long.Parse(oiTxt.Text), Quantity = q, ItemPrice = p.Price, ItemName = p.ItemName, Amount = a }; //orderItems.Add(new OrderItem { ItemId = long.Parse(fiCbo.SelectedValue.ToString()), OrderId = long.Parse(oiTxt.Text), Quantity = (int)numericUpDown1.Value }); bs.Insert(bs.Count, item); }
private void btnInsertBefore_Click(object sender, EventArgs e) { if (dgvPurchaseOrderLine.CurrentCell == null) { btnAddRow_Click(null, null); return; } ORD_PurchaseOrderLineResult rst = new ORD_PurchaseOrderLineResult(); InitNewData(rst); bsOrderLine.Insert(dgvPurchaseOrderLine.CurrentRow.Index, rst); }
/// <summary> /// Insert a row of type 'Ticket' at specified row index /// </summary> /// <param name="rowIindex"> row index</param> /// <param name="t"> ticket step object</param> private void InsertRow(int rowIindex, TicketStepType t) { try { BindingSource bs = (BindingSource)this.ticketStepTypeListBindingSource; bs.Insert(rowIindex, t); } catch (Exception) { throw; } }
//checks if a RomMatch with the same ID is already in the BindingSource, if so it's status is reset else it's added bool checkRow(RomMatch romMatch) { if (importerBindingSource.Contains(romMatch)) { return(true); } foreach (DataGridViewRow row in importGridView.Rows) { //Game already in gridview, must be previously ignored. Reset status and return RomMatch rowRomMatch = (RomMatch)row.DataBoundItem; if (romMatch.ID == rowRomMatch.ID) { int rowNum = row.Index; importerBindingSource.RemoveAt(rowNum); romMatch.BindingSourceIndex = rowRomMatch.BindingSourceIndex; importerBindingSource.Insert(rowNum, romMatch); return(true); } } return(false); }
private void buttonMoveRowUp_Click(object sender, EventArgs e) { int position = m_BindingSource.Position; if (position == 0) { return; // already at top } m_BindingSource.RaiseListChangedEvents = false; UpdatedFiles current = (UpdatedFiles)m_BindingSource.Current; m_BindingSource.Remove(current); position--; m_BindingSource.Insert(position, current); m_BindingSource.Position = position; m_BindingSource.RaiseListChangedEvents = true; m_BindingSource.ResetBindings(false); }
public void MoveNext() { //if (SelectedItems.Count > 0) // BindingSource.Move(SelectedItems[0], SelectedItems[0].Index + 1); return; try { var img = BindingSource.Current as ImageDocument; var i = BindingSource.IndexOf(img) + 1; if (i < BindingSource.Count) { BindingSource.RemoveCurrent(); BindingSource.Insert(i, img); BindingSource.Position = i; } } catch (Exception) { } return; SortColumn = ColumnType.Name; if (SelectedItems.Count > 0) { foreach (var item in SelectedItems) { if (item.Index <= (Items.Count - 2)) { item.ZOrder += 1; item.Text = item.ZOrder.ToString(); (item.Tag as ImageDocument).OrderInDocument = item.ZOrder; Items[item.Index + 1].ZOrder -= 1; Items[item.Index + 1].Text = Items[item.Index + 1].ZOrder.ToString(); (Items[item.Index + 1].Tag as ImageDocument).OrderInDocument = Items[item.Index + 1].ZOrder; } } } Sort(); }
private void cmdAdd_Click(object sender, EventArgs e) { newRow = true; Item item = manager.AddNewTimesheet(); if (bindingSource1.Count == 0) { bindingSource1.Add(item); } else { bindingSource1.Insert(0, item); } }
private void dataView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { int rowIndex = e.RowIndex; if (e.RowIndex > -1) { DataGridViewRow dgvr = dataView1.Rows[rowIndex]; if (dgvr.Cells[e.ColumnIndex].Value.ToString() == "修改") { FrmMaterialEdit frm = new FrmMaterialEdit(); frm.Text = "助剂修改"; frm.currentMaterial = (DsMaterial)bindingSource.Current; if (frm.ShowDialog() == DialogResult.OK) { bindingSource.RemoveAt(e.RowIndex); bindingSource.Insert(e.RowIndex, frm.currentMaterial); } } else if (dgvr.Cells[e.ColumnIndex].Value.ToString() == "删除") { bindingSource.RemoveCurrent(); } } }
private void dataGridViewPluginList_DragDrop(object sender, DragEventArgs e) { // The mouse locations are relative to the screen, so they must be // converted to client coordinates. Point clientPoint = dataGridViewPluginList.PointToClient(new Point(e.X, e.Y)); // Get the row index of the item the mouse is below. rowIndexOfItemUnderMouseToDrop = dataGridViewPluginList.HitTest(clientPoint.X, clientPoint.Y).RowIndex; // If the drag operation was a move then remove and insert the row. if (e.Effect == DragDropEffects.Move && pluginsDataSource.Count > rowIndexFromMouseDown) { WindowPlugin pluginToMove = (WindowPlugin)pluginsDataSource[rowIndexFromMouseDown]; pluginsDataSource.RemoveAt(rowIndexFromMouseDown); pluginsDataSource.Insert(rowIndexOfItemUnderMouseToDrop, pluginToMove); } }
private void addSellButton_OnClick(object sender, EventArgs e) { int qty = int.Parse(AddQtyTextBox.Text); double px = double.Parse(AddPxTextbox.Text); BindingSource bs = (BindingSource)askDataGridView.DataSource; int index = 0; foreach (DisplayOrder o in bs) { if (o.Px > px) { break; } index++; } bs.Insert(index, new DisplayOrder(px, qty)); }
/// <summary> /// Adds the current stream URL to history list (and removes the last one if /// there are more than 10 entries in the list). Also saves the current /// livestreamer.exe location in the Application Data object. /// </summary> private void UpdateHistory() { _applicationData.LivestreamerLoc = tbLivestreamerLoc.Text; if (_applicationData.Urls.Count > 9) { _applicationData.Urls.RemoveAt(_applicationData.Urls.Count - 1); } _urlsBinding.Insert(0, cbStreamURLs.Text); cbStreamURLs.SelectedIndex = 0; #if DEBUG foreach (string url in _applicationData.Urls) { AddOutput("URL: " + url); } #endif }
private void MoveRow(int amount) { var selectedIdx = ActiveParamsDGV.SelectedRows[0].Index; var newIdx = selectedIdx + amount; var item = activeParamsBs[selectedIdx]; if (newIdx < 0) { newIdx = activeParamsBs.Count - 1; } if (newIdx >= activeParamsBs.Count) { newIdx = 0; } activeParamsBs.RemoveAt(selectedIdx); activeParamsBs.Insert(newIdx, item); ActiveParamsDGV.Rows[newIdx].Selected = true; }
private void reactionsDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (reactionsDataGridView.Columns[e.ColumnIndex].Name == "Smazat") { reakce.RemoveAt(e.RowIndex); return; } Reakce edited = (Reakce)reakce[e.RowIndex]; OknoReakce r1 = new OknoReakce(edited.Filtr, edited.Nazev, edited.Typ, edited.Zdroj, edited.Popis, edited.Email, edited.TextEmailu, edited.CestaKProgramu, edited.TypNove, edited.PopisNove); r1.ShowDialog(); if (!r1.success) { return; } Reakce reakce1 = r1.reakce1; reakce.RemoveAt(e.RowIndex); reakce.Insert(e.RowIndex, reakce1); zmizet(); }
void moveDisc(DataGridViewRow selectedRow, int increment) { int index = selectedRow.Index; object item = selectedRow.DataBoundItem; if (increment == 0 || (increment < 0 && index == 0) || (increment > 0 && index > discBindingSource.Count - 2)) { return; } discBindingSource.RemoveAt(index); index = index + increment; discBindingSource.Insert(index, item); discGridView.ClearSelection(); selectedRow = discGridView.Rows[index]; selectedRow.Selected = true; updateDiscNumbers(); saveDiscs = true; }
// Handles row dropping in another position protected override void OnDragDrop(DragEventArgs e) { Point clientPoint = PointToClient(new Point(e.X, e.Y)); RowIndexToDrop = HitTest(clientPoint.X, clientPoint.Y).RowIndex; if (!RowIndexValid(RowIndexToDrop)) { base.OnDragDrop(e); return; } if (e.Effect == DragDropEffects.Move) { DataGridViewRow rowToMove = e.Data.GetData(typeof(DataGridViewRow)) as DataGridViewRow; BindingSource bindingSource = DataSource as BindingSource; if (bindingSource == null) { base.OnDragDrop(e); return; } var accToMove = bindingSource[rowToMove.Index]; if (accToMove == null) { base.OnDragDrop(e); return; } bindingSource.RemoveAt(clickedRowIndex); bindingSource.Insert(RowIndexToDrop, accToMove); ClearGridSelections(); Rows[RowIndexToDrop].Selected = true; } base.OnDragDrop(e); }
private void MoveSelectedItem(int offset) { if (PackageSourcesListBox.SelectedItem == null) { return; } int oldIndex = PackageSourcesListBox.SelectedIndex; int newIndex = oldIndex + offset; if (newIndex < 0 || newIndex > PackageSourcesListBox.Items.Count - 1) { return; } var item = PackageSourcesListBox.SelectedItem; _allPackageSources.Remove(item); _allPackageSources.Insert(newIndex, item); PackageSourcesListBox.SelectedIndex = newIndex; UpdateUI(); }