tentavarious
asked on
changing font size within datagrid cell
Hello experts, i am using a webform with a datagrid. Within the itemdatabound event of my datagrid i am trying to change the font size of text, within the datagrid cells. I cant remeber how to change the font size below is what i tried.
Private Sub dgactive_ItemDataBound(ByV al sender As Object, ByVal e As System.Web.UI.WebControls. DataGridIt emEventArg s) Handles dgactive.ItemDataBound
'handles the datagrid load
If e.Item.ItemType <> ListItemType.Header And e.Item.ItemType <> ListItemType.Footer Then
' if some condition is met set the text of the cell
e.Item.Cells(2).Text = "Active"
e.Item.Cells(2).Font = New Font("Arial", 14)
e.Item.Cells(2).ForeColor = Color.Green
' Else
e.Item.Cells(2).Text = "Not Active"
e.Item.Cells(2).ForeColor = Color.Red
' End If
End If
End Sub
Private Sub dgactive_ItemDataBound(ByV
'handles the datagrid load
If e.Item.ItemType <> ListItemType.Header And e.Item.ItemType <> ListItemType.Footer Then
' if some condition is met set the text of the cell
e.Item.Cells(2).Text = "Active"
e.Item.Cells(2).Font = New Font("Arial", 14)
e.Item.Cells(2).ForeColor = Color.Green
' Else
e.Item.Cells(2).Text = "Not Active"
e.Item.Cells(2).ForeColor = Color.Red
' End If
End If
End Sub
ASKER
Nope that doesnt work i get syntax errors "value type integer cannot be converted to System.Web.UI.Webcontrols. FontUnit
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Private Sub dgactive_ItemDataBound(ByV
'handles the datagrid load
If e.Item.ItemType <> ListItemType.Header And e.Item.ItemType <> ListItemType.Footer Then
' if some condition is met set the text of the cell
e.Item.Cells(2).Text = "Active"
e.Item.Cells(2).Font.Name = "Arial"
e.Item.Cells(2).Font.Size = 14
e.Item.Cells(2).ForeColor = Color.Green
' Else
e.Item.Cells(2).Text = "Not Active"
e.Item.Cells(2).ForeColor = Color.Red
' End If
End If
End Sub
-tushar