質問

Iは、行ヘッダと列ヘッダを.NETコンポーネントのDataGridViewを使用して、画像からカスタムの背景を与えたいです。それもこれを行うことは可能ですか?そしてもしそうなら、どのように?

私は、Visual Studio 2008、WindowsアプリケーションやC#を使用します。

役に立ちましたか?

解決

のDataGridViewの行ヘッダの属性を変更するために、その可能。あなたはどちらか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