开发者

How can I change the font in a DataGrid?

I am using:

dg开发者_StackOverflow.ForeColor = System.Drawing.Color.Black;
dg.BackColor = System.Drawing.Color.Beige;

to set the background and foreground color of a DataGrid. How can I change the font to say Calibri or any others using the built-in methods.


If this is a web application, the DataGrid class already provides a Font property that you can set to
a font of your choosing. You can set it either from the designer or in your source code, just as you've set the BackColor and ForeColor properties.

However, as I mentioned in a comment, you should be very careful about setting controls to use a font that the user might not have installed on their computer. I recommend checking a list of web-safe fonts.


You can change the font with this code

dg.Font=new Font(string familyName,int size);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜