[英]How to edit a Gridview column font from code behind?
I want to edit certain column font size我想编辑某些列字体大小
/*Line 47*/ GridView1.HeaderRow.Cells[0].Text = "";
/*Line 48*/ GridView1.Columns[0].ControlStyle.Font.Size= 40; // the bug is here
/*Line 49*/ GridView1.HeaderRow.Cells[1].Text = "Report Name";
Line 48 gives error:第 48 行给出错误:
Index was out of range.指数超出范围。 Must be non-negative and less than the size of the collection.必须是非负数且小于集合的大小。
Parameter name: index参数名称:索引
//First Use Header File //首先使用Header文件
using System.Drawing;使用 System.Drawing;
// than // 比
BridView1.ControlStyle.Font.Size = 9;
Columns property references the columns in your grid-view setup, if you wanted to just access a targeted column in a specific row then: Columns 属性引用网格视图设置中的列,如果您只想访问特定行中的目标列,则:
GridView1.Rows[0].Cells[0].ControlStyle.Font.Size = 40;
Would be used, otherwise you may as well just set the ControlStyle in your column when you construct it (either in code or designer).将被使用,否则您也可以在构造它时在列中设置 ControlStyle(在代码或设计器中)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.