문제

.NET 구성 요소 DatagridView를 사용하여 행 헤더 및 열 헤더에 이미지에서 사용자 정의 배경을 제공하고 싶습니다. 이것을 할 수 있습니까? 그렇다면 어떻게?

Visual Studio 2008, Windows Application, C#을 사용합니다.

도움이 되었습니까?

해결책

DataGridView RowHeader의 속성을 변경할 수 있습니다. CellPainting 또는 RowPostPaint 이벤트를 처리하고 행 헤더 셀에 이미지를 수동으로 그려야합니다.

 protected override void  OnRowPostPaint(DataGridViewRowPostPaintEventArgs e)
        {
             // Your code to insert image/content per cell goes here    
        }

다른 팁

이를 수행하는 방법은 이와 같은 RowDatabound 이벤트에 헤더 요소 당 CSSCLASS 이름을 넣고 CSS에 배경 이미지를 할당하는 것입니다.

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header)
        {
            foreach (TableCell c in e.Row.Cells)
            {
                c.CssClass = "bgimage";
            }
        }
    }

CSS :

.bgimage{ background-image:url(images/arrow-red-large-down.gif);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top