2016-10-10 1 views
-2

나는 아래와 같은 DataGridView에 있습니다셀의 투명한 알파 컬러를 만드는 방법 datagridview?

enter image description here

내가 셀 된 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(); 
} 

모든 팁은 큰 도움이 될 것입니다. 미리 감사드립니다.

+0

WPF 또는 기본 양식입니까? – Kyon

+0

명확하게 설명하지 못해 죄송합니다. 이것은 기본 양식, Windows 양식 응용 프로그램입니다. – MinhKiyo

+0

Color.FromArgb (흰색, 컬러)를 사용해 보셨습니까? https://msdn.microsoft.com/pt-br/library/1hstcth9(v=vs.110).aspx – Magnetron

답변

관련 문제