Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Set fonts for grid dynamically

Reply
Thread Tools

Set fonts for grid dynamically

 
 
Eagle
Guest
Posts: n/a
 
      05-18-2005
Okay, I know you can set up a grid in html (see code below), but I want to
be able to do it dynamically, can someone help with the syntax? I've tried:
dg.Font = "Microsoft Sans Serif"
dg.Font.Name="Microsoft Sans Serif"
dg.Font.Names="Microsoft Sans Serif"
dg.Font.Size="8pt"
dg.Font.Size.unit=??????

Can you tell me how to do all of the below in code behind? Thanks.

<asp:datagrid id=dg runat="server"
EnableViewState=True BorderStyle="Double" GridLines="Horizontal"
BorderWidth="3px" BorderColor="#ccbccc" BackColor="White" CellPadding="4"
AutoGenerateColumns="False">
<FooterStyle ForeColor="#ccbccc" BackColor="White">
</FooterStyle>

<SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#339966">
</SelectedItemStyle>

<EditItemStyle ForeColor="Black" BackColor="Silver" CssClass="DDL">
</EditItemStyle>

<ItemStyle ForeColor="#333333" BackColor="White">
</ItemStyle>

<HeaderStyle Font-Underline="True" Font-Bold="True" Wrap="False"
ForeColor="White" BackColor="#cccccc">
</HeaderStyle>


 
Reply With Quote
 
 
 
 
Ken Cox [Microsoft MVP]
Guest
Posts: n/a
 
      05-18-2005
Hi ???

Here's some examples to get you going. Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]


If Not IsPostBack Then
Dim dg As New DataGrid
dg.ID = "dg"
dg.EnableViewState = True
dg.BorderStyle = BorderStyle.Double
dg.GridLines = GridLines.Horizontal
dg.BorderWidth = Unit.Parse("3px",
System.Globalization.CultureInfo.InvariantCulture)
dg.BorderColor = Color.FromArgb(204, 188, 204)
dg.BackColor = Color.White
dg.ForeColor = Color.Black
dg.CellPadding = 4
dg.ItemStyle.ForeColor = Color.Black
dg.AutoGenerateColumns = True
dg.Font.Size = FontUnit.Point(12)
dg.Font.Underline = False
dg.FooterStyle.ForeColor = Color.FromArgb(204, 188, 204)
dg.FooterStyle.BackColor = Color.White
dg.HeaderStyle.Font.Underline = True
dg.HeaderStyle.Font.Bold = True
dg.HeaderStyle.Wrap = False
dg.ForeColor = Color.White
'.... and so on.

dg.DataSource = CreateDataSource()
dg.DataBind()
PlaceHolder1.Controls.Add(dg)

http://msdn.microsoft.com/library/de...classtopic.asp

"Eagle" <(E-Mail Removed)> wrote in message
news:OjGgjW%(E-Mail Removed)...
> Okay, I know you can set up a grid in html (see code below), but I want to
> be able to do it dynamically, can someone help with the syntax? I've
> tried:
> dg.Font = "Microsoft Sans Serif"
> dg.Font.Name="Microsoft Sans Serif"
> dg.Font.Names="Microsoft Sans Serif"
> dg.Font.Size="8pt"
> dg.Font.Size.unit=??????
>
> Can you tell me how to do all of the below in code behind? Thanks.
>
> <asp:datagrid id=dg runat="server"
> EnableViewState=True BorderStyle="Double" GridLines="Horizontal"
> BorderWidth="3px" BorderColor="#ccbccc" BackColor="White" CellPadding="4"
> AutoGenerateColumns="False">
> <FooterStyle ForeColor="#ccbccc" BackColor="White">
> </FooterStyle>
>
> <SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#339966">
> </SelectedItemStyle>
>
> <EditItemStyle ForeColor="Black" BackColor="Silver" CssClass="DDL">
> </EditItemStyle>
>
> <ItemStyle ForeColor="#333333" BackColor="White">
> </ItemStyle>
>
> <HeaderStyle Font-Underline="True" Font-Bold="True" Wrap="False"
> ForeColor="White" BackColor="#cccccc">
> </HeaderStyle>
>
>



 
Reply With Quote
 
 
 
 
Eagle
Guest
Posts: n/a
 
      05-19-2005
How about how to set the Font Name?? Like Times New Roman or Microsoft Sans
Serif?

"Ken Cox [Microsoft MVP]" <(E-Mail Removed)> wrote in message
news:%23WIT15$(E-Mail Removed)...
> Hi ???
>
> Here's some examples to get you going. Let us know if this helps?
>
> Ken
> Microsoft MVP [ASP.NET]
>
>
> If Not IsPostBack Then
> Dim dg As New DataGrid
> dg.ID = "dg"
> dg.EnableViewState = True
> dg.BorderStyle = BorderStyle.Double
> dg.GridLines = GridLines.Horizontal
> dg.BorderWidth = Unit.Parse("3px",
> System.Globalization.CultureInfo.InvariantCulture)
> dg.BorderColor = Color.FromArgb(204, 188, 204)
> dg.BackColor = Color.White
> dg.ForeColor = Color.Black
> dg.CellPadding = 4
> dg.ItemStyle.ForeColor = Color.Black
> dg.AutoGenerateColumns = True
> dg.Font.Size = FontUnit.Point(12)
> dg.Font.Underline = False
> dg.FooterStyle.ForeColor = Color.FromArgb(204, 188, 204)
> dg.FooterStyle.BackColor = Color.White
> dg.HeaderStyle.Font.Underline = True
> dg.HeaderStyle.Font.Bold = True
> dg.HeaderStyle.Wrap = False
> dg.ForeColor = Color.White
> '.... and so on.
>
> dg.DataSource = CreateDataSource()
> dg.DataBind()
> PlaceHolder1.Controls.Add(dg)
>
>

http://msdn.microsoft.com/library/de...classtopic.asp
>
> "Eagle" <(E-Mail Removed)> wrote in message
> news:OjGgjW%(E-Mail Removed)...
> > Okay, I know you can set up a grid in html (see code below), but I want

to
> > be able to do it dynamically, can someone help with the syntax? I've
> > tried:
> > dg.Font = "Microsoft Sans Serif"
> > dg.Font.Name="Microsoft Sans Serif"
> > dg.Font.Names="Microsoft Sans Serif"
> > dg.Font.Size="8pt"
> > dg.Font.Size.unit=??????
> >
> > Can you tell me how to do all of the below in code behind? Thanks.
> >
> > <asp:datagrid id=dg runat="server"
> > EnableViewState=True BorderStyle="Double" GridLines="Horizontal"
> > BorderWidth="3px" BorderColor="#ccbccc" BackColor="White"

CellPadding="4"
> > AutoGenerateColumns="False">
> > <FooterStyle ForeColor="#ccbccc" BackColor="White">
> > </FooterStyle>
> >
> > <SelectedItemStyle Font-Bold="True" ForeColor="White"

BackColor="#339966">
> > </SelectedItemStyle>
> >
> > <EditItemStyle ForeColor="Black" BackColor="Silver" CssClass="DDL">
> > </EditItemStyle>
> >
> > <ItemStyle ForeColor="#333333" BackColor="White">
> > </ItemStyle>
> >
> > <HeaderStyle Font-Underline="True" Font-Bold="True" Wrap="False"
> > ForeColor="White" BackColor="#cccccc">
> > </HeaderStyle>
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamically set the width of the grid by percentage eagle ASP .Net Datagrid Control 0 12-01-2005 11:19 PM
How to transfer a value from an Invisible Grid to an visible Grid =?Utf-8?B?QXNzYW5LaGFuIElzbWFpbA==?= ASP .Net 2 10-17-2005 03:56 AM
Grid within a Grid ItemDataBound event problem Girish ASP .Net 4 07-19-2005 01:17 AM
Fonts suddenly unreadable in IE 6.0 - All other system fonts appear normal Emily Computer Support 3 06-09-2005 04:52 AM
asp fonts problems (chinese fonts become ??????) sam ASP General 0 06-06-2004 06:15 AM



Advertisments