示例#1
0
        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");
                    }
                }
            }
        }
示例#2
0
        public void DataGridViewSelectedCellCollection_Contains_InvokeEmpty_ReturnsFalse(DataGridViewCell dataGridViewCell)
        {
            using var control = new DataGridView();
            DataGridViewSelectedCellCollection collection = control.SelectedCells;

            Assert.False(collection.Contains(dataGridViewCell));
        }
示例#3
0
        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));
        }
示例#4
0
        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";
        }