[英]Change all of the cell border colors in a GridView to red
嗨,我嘗試使用下面顯示的代碼從后面的代碼中更改GridView
所有垂直和水平線,但這似乎沒有任何效果。
任何人都可以提供帶有背后代碼的解決方案嗎?
foreach (GridViewRow row in gvCurrentStageCircsPSTN.Rows)
{
foreach (TableCell cell in row.Cells)
{
cell.Width = 150;
cell.Height = 20;
cell.Attributes.CssStyle["text-align"] = "center";
}
}
如您所確認的,下面的方法是有效的。 大!
border-style:solid; border-width:1px;
現在用於標題gridview.HeaderRow.Cells[0].CssClass = "something"
。 試試看
注意-僅在AutogenerateColumns = False時有效,對True無效(默認值!)
但是正如Claudio正確指出的那樣,所有樣式都應該是css文件的一部分,並且您應該使用css類訪問它們(最好僅從UI而不是后面的代碼訪問它們)。
使用@dumass建議的CSS實現了此目的
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.