private void dataGridView1_SelectionChanged(object sender, EventArgs e) { DataGridViewSelectedCellCollection cells = dataGridView1.SelectedCells; foreach (DataGridViewCell cell in cells) { int rowidx = cell.RowIndex; int colidx = cell.ColumnIndex; if (colidx > 0) { dataGridView1.Rows[rowidx].Cells[colidx].Style.Format = "F0"; } } for (int a = 0; a < dataGridView1.Rows.Count; a++) { for (int b = 3; b < dataGridView1.Columns.Count; b++) { if (!cells.Contains(dataGridView1.Rows[a].Cells[b])) { Int64 buf; dataGridView1.Rows[a].Cells[b].Style.Format = "C0"; dataGridView1.Rows[a].Cells[b].Style.FormatProvider = CultureInfo.GetCultureInfo("id-ID"); } } } }
public void DataGridViewSelectedCellCollection_Contains_InvokeEmpty_ReturnsFalse(DataGridViewCell dataGridViewCell) { using var control = new DataGridView(); DataGridViewSelectedCellCollection collection = control.SelectedCells; Assert.False(collection.Contains(dataGridViewCell)); }
public void DataGridViewSelectedCellCollection_Contains_InvokeNotEmpty_ReturnsExpected() { using var control = new DataGridView { RowCount = 3, ColumnCount = 1, SelectionMode = DataGridViewSelectionMode.CellSelect }; control.Rows[0].Cells[0].Selected = true; control.Rows[1].Cells[0].Selected = false; control.Rows[2].Cells[0].Selected = true; DataGridViewSelectedCellCollection collection = control.SelectedCells; Assert.True(collection.Contains(control.Rows[0].Cells[0])); Assert.False(collection.Contains(control.Rows[1].Cells[0])); Assert.True(collection.Contains(control.Rows[2].Cells[0])); Assert.False(collection.Contains(new SubDataGridViewCell())); Assert.False(collection.Contains(null)); }
private void fileDataGrid_CellStateChanged(object sender, DataGridViewCellStateChangedEventArgs e) { DataGridViewElementStates state = e.StateChanged; DataGridViewSelectedCellCollection SelectedFiles = fileDataGrid.SelectedCells; int numFilesRemove = SelectedFiles.Count; if (SelectedFiles.Contains(fileDataGrid[0, fileDataGrid.RowCount - 1])) { numFilesRemove--; } btn_Remove.Text = $"Delete ({numFilesRemove}) Files"; }