以下的范例就是将GridView的内框线设为蓝色。
- Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
- GridView1.Attributes("bordercolor") = System.Drawing.ColorTranslator.ToHtml(Drawing.Color.Blue)
- End Sub
我们也可以扩展GridView控制项,加入一个GridLineColor属性,用来设定GridView的内框线颜色。
- Imports System
- Imports System.Collections.Generic
- Imports System.ComponentModel
- Imports System.Text
- Imports System.Web
- Imports System.Web.UI
- Imports System.Web.UI.WebControls
- Imports System.Drawing
-
- < _
- Description("GridView控制项"), _
- ToolboxData("<{0}:TBGridView runat=server></{0}:TBGridView>") _
- > _
- Public Class TBGridView
- Inherits GridView
- Private FGridLineColor As Color
-
-
-
-
- < _
- Description("GridView格线颜色"), _
- TypeConverter(GetType(WebColorConverter)), _
- Category("Appearance"), _
- DefaultValue(GetType(Color), "")> _
- Public Property GridLineColor() As Color
- Get
- Return FGridLineColor
- End Get
- Set(ByVal value As Color)
- FGridLineColor = value
- End Set
- End Property
-
-
-
-
-
- Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
- If Me.GridLineColor <> Drawing.Color.Empty Then
- Me.Attributes("bordercolor") = System.Drawing.ColorTranslator.ToHtml(Me.GridLineColor)
- End If
- MyBase.Render(writer)
- End Sub
- End Class
|