views:

46

answers:

1

How change gridview font?in windows form

+1  A: 

You can use the ItemStyle-Font-Names property on each BoundField to change the font of the items in the grid, and you can use the HeaderStyle-Font-Names property to change the headers.

If you want to use css, read on...

You can also use a HeaderStyle-CssClass="gridview-header", then you could define a css class to do the styling:

.gridview-header
{
    font-weight: bold;
    font-size: 10px;
    padding-bottom: 3px;
    color:  #666666;
    padding-top: 3px;
    font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
    background-color: #EEEEEE;
}

And you could define a css class for the entire gridview, by setting the gridview's CssClass property:

CssClass="gridview"

Then, you can set the tr property (the tr is what the gridview renders for rows) and set the font there in your css file:

.gridview tr
{
    /* set font properties here */
}

When using css in a project, you usually have a css file (call it StyleSheet.css, for example). Then in your aspx pages (or views if you're using MVC), you can include the stylesheet like this, assuming the StyleSheet.css is in a folder called Styles in the site root folder:

<head id="Head1" runat="server">
    <link href="Styles/StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
dcp
thanksi made css in class in vb.netwhere do i write css?in style?explain more,please
niloofar
@niloofar - See my latest edit.
dcp