-2
私は以下のようにDataGridViewのを持っている:セルのdatagridviewの透明なアルファ色を作る方法は?
私は、セルのDataGridViewの背景色をしたいと思い約20%、50%、...透明(完全に透明ではない)があり、背景色(黒、紫、灰色など)?
私は多くの方法を試してみましたが、私はそれを行うことができないのです。これらの
private void CustomerDGV_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
try
{
// Black 20%
if (e.ColumnIndex == 1)
{
SetCellsTransparent(e.RowIndex, Color.Black, 0.2);
}
// Purple 50%
if (e.ColumnIndex == 2)
{
SetCellsTransparent(e.RowIndex, Color.Purple, 0.5);
}
// Gray 100%
if (e.ColumnIndex == 3)
{
SetCellsTransparent(e.RowIndex, Color.Gray, 1);
}
}
catch (Exception) { }
}
public void SetCellsTransparent(int rowIdx, Color color, double transparency)
{
//Color color = ColorTranslator.FromHtml("#000000");
//Color color = Color.Red;
//this.Rows[rowIdx].Cells[0].Style.BackColor = color;
//this.Rows[rowIdx].Cells[0].Style.BackColor = Color.FromArgb(50, color);
var whiteness = 255 - Convert.ToInt32(transparency * 255);
this.Rows[rowIdx].Cells[0].Style.BackColor = Color.FromArgb(255, whiteness, whiteness); //Red
this.ClearSelection();
}
任意のヒントは、大きな助けとなります。前もって感謝します。
これはWPFまたは基本フォームですか、使用していますか? – Kyon
明確に説明できないのは残念です。これは基本的なフォーム、Windowsフォームアプリケーションです。 – MinhKiyo
Color.FromArgb(白、色)を試しましたか? https://msdn.microsoft.com/pt-br/library/1hstcth9(v=vs.110).aspx – Magnetron