0
私はDataGridView
に「プログラム」で追加したDataGridViewRow
を持っています。私は細胞の1つをDataGridViewButtonCell
にしたいのでクリックしてください。 (私はのon_clickのdatagridviewのハンドラを持つことができますが、コードの単純化のためにこの方法を使いたいと思います)。クリック時のDataGridViewButtonCellボタンの色の変更
DataGridViewButtonCellのフォアカラー/バックカラーを設定したいと考えています。
DataGridViewRow dgvRow = new DataGridViewRow();
dgvRow = (DataGridViewRow)dgv.Rows[0].Clone();
dgvRow.Cells[0].Value = filename;
dgvRow.Cells[0].Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
DataGridViewButtonCell dgvBtn = new DataGridViewButtonCell();
dgvRow.Cells[1].Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
dgvBtn.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
dgvBtn.Style.BackColor = Color.Green; //this sets the color of the cell, not the button in the cell.
Q:セルに表示されるボタンの色を設定するにはどうすればよいですか?かなり多くのあなたがBackColor
を変更することFlatStyle
Button
ようにする必要があり、通常のButton
と同様