繁体   English   中英

更改DataGrid单元的字体?

[英]Changing The Font Of A DataGrid Cell?

我的简单目标是使特定单元格内的字体加粗。 我无法设置Style.Font.Bold属性,因为它是只读的,但是我可以将Style.Font设置为新的Font对象。 如何创建一个Font对象,以使其在特定单元格内的文本变为粗体?

grid.Rows[0].Cells[0].Style.Font = new Font(???);

谢谢Stack-O!

如果我们正在谈论WinForms,则可以这样操作...

var cell = grid.Rows[0].Cells[0];
cell.Style.Font = new Font(cell.Style.Font, FontStyle.Bold);

如果我们正在谈论Web应用程序,则可以这样操作...

grid.Rows[0].Cells[0].Style("font-weight", "bold");

但是理想情况下,在网络应用中,这可以通过CSS使用特定的选择器进行处理...

#GridView1 > tr:first-child > td:first-child {
  font-weight: bold;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM