我想给行标题和列标题使用.NET组件的DataGridView的图像的自定义的背景。是否有可能甚至做到这一点?如果是这样,怎么样?

我使用Visual Studio 2008,Windows应用程序,C#。

有帮助吗?

解决方案

其能够改变的datagridview的rowHeader的属性。您需要任一处理CellPainting或RowPostPaint事件并手动行标题细胞绘制图像。

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

其他提示

在这样做,这是把每个标题元素的名称的CssClass在RowDataBound事件是这样,并在指定的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