private void GridView_Command_UpdateRelatedDataGridHandler(UpdateDirection direction, int rowIndex, int columnIndex) { if (rowIndex < 0 || rowIndex >= _dataSource.Count) { return; } CommandManagementItem cmdMngItem = _dataSource[rowIndex]; switch (direction) { case UpdateDirection.Select: { LoadCommandSecurities(cmdMngItem); var firstCmdItem = _dataSource.First(p => p.Selection); if (firstCmdItem != null) { LoadCommandSummary(firstCmdItem); } } break; case UpdateDirection.UnSelect: { var secuItems = _secuDataSource.Where(p => p.CommandId == cmdMngItem.CommandId).ToList(); foreach (var secuItem in secuItems) { _secuDataSource.Remove(secuItem); } var entrustItems = _entrustDataSource.Where(p => p.CommandId == cmdMngItem.CommandId).ToList(); foreach (var entrustItem in entrustItems) { _entrustDataSource.Remove(entrustItem); } var dealItems = _dealDataSource.Where(p => p.CommandId == cmdMngItem.CommandId).ToList(); foreach (var dealItem in dealItems) { _dealDataSource.Remove(dealItem); } var selectedItems = _dataSource.Where(p => p.Selection).ToList(); if (selectedItems != null && selectedItems.Count > 0) { LoadCommandSummary(selectedItems[0]); } else { LoadCommandSummary(_dataSource[0]); } } break; default: break; } }
public void LogSizeNumericUpDown_ValueChanged(object sender, EventArgs e) { while (LogList.Count >= LogSize) { var first = LogList.First(); LogList.Remove(first); } }
void Sort(string key, bool ascending) { if (_bindingList.Any()) // only sort if array contains something { var comparer = _bindingList.First().GetComparer(key, ascending); if (comparer != null) { _bindingList.Sort(comparer); } } }
private void PasteClipboard() { DataObject dObject = (DataObject)Clipboard.GetDataObject(); if (dObject.GetDataPresent(DataFormats.Text)) { string[] pastedRows = Regex.Split(dObject.GetData(DataFormats.Text).ToString().TrimEnd("\r\n".ToCharArray()), "\r\n"); SortableBindingList <Data> contractList = new SortableBindingList <Data>(); foreach (string pastedRow in pastedRows) { string[] pastedRowCells = pastedRow.Split(new char[] { '\t' }); if (pastedRowCells.Length > 0) { contractList.Add(new Data { Contract = pastedRowCells[0] }); //, Status = pastedRowCells[1] } } //list of status SortableBindingList <Data> itemStatus = new SortableBindingList <Data>() { new Data { Contract = "1", Status = "Completed" }, new Data { Contract = "4", Status = "Closed" }, new Data { Contract = "2", Status = "Pre-close" }, new Data { Contract = "3", Status = "INVALID" }, }; foreach (var i in itemStatus) { var itemToChange = contractList.First(c => c.Contract == i.Contract).Status = i.Status; } LoadList(contractList); } }
protected override void WndProc(ref Message m) { base.WndProc(ref m); if (m.Msg == HOTKEY_MSG) { int hotKeyCol = dataGridView1.Columns.IndexOf(HotKey); int readOnlyColIndx = dataGridView1.Columns.IndexOf(ReadOnly); for (int i = 0; i < dataGridView1.Rows.Count; i++) { if ((bool)dataGridView1.Rows[i].Cells[hotKeyCol].Value) { string fileName = dataGridView1.Rows[i].Cells[0].Value.ToString(); var saveFile = _borderlands3FilesList.First(a => a.FileName == fileName); if (saveFile != null) { saveFile.IsReadOnly = !saveFile.IsReadOnly; } dataGridView1.InvalidateRow(i); } } } }