DataGrid.CreateControlStyle 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
새 컨트롤 스타일을 만듭니다.
protected:
override System::Web::UI::WebControls::Style ^ CreateControlStyle();
protected override System.Web.UI.WebControls.Style CreateControlStyle ();
override this.CreateControlStyle : unit -> System.Web.UI.WebControls.Style
Protected Overrides Function CreateControlStyle () As Style
반환
새 스타일을 나타내는 Style입니다.
예제
다음 코드 예제에는 재정의 하는 방법을 보여 줍니다.는 CreateControlStyle 항상 표시 되도록 컨트롤을 사용자 지정 서버에서 메서드를 GridLines 없이 CellSpacing 에 DataGrid합니다.
<%@ Page language="c#" %>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Custom DataGrid - CreateControlStyle - C# Example</title>
</head>
<body>
<form id="Form1" method="post" runat="server">
<h3>Custom DataGrid - CreateControlStyle - C# Example</h3>
<aspSample:CustomDataGridCreateControlStyle id="Datagrid1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:HyperLinkColumn Text="www.microsoft.com" Target="_blank" HeaderText="HyperLinks" NavigateUrl="http://www.microsoft.com" />
</Columns>
</aspSample:CustomDataGridCreateControlStyle>
</form>
</body>
</html>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB" %>
<%@ Page language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Custom DataGrid - CreateControlStyle - VB.NET Example</title>
</head>
<body>
<form id="Form1" method="post" runat="server">
<h3>Custom DataGrid - CreateControlStyle - C# Example</h3>
<aspSample:CustomDataGridCreateControlStyle id="Datagrid1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:HyperLinkColumn Text="www.microsoft.com" Target="_blank" HeaderText="HyperLinks" NavigateUrl="http://www.microsoft.com" />
</Columns>
</aspSample:CustomDataGridCreateControlStyle>
</form>
</body>
</html>
using System.Web;
using System.Security.Permissions;
namespace Samples.AspNet.CS.Controls
{
[AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class CustomDataGridCreateControlStyle : System.Web.UI.WebControls.DataGrid
{
protected override System.Web.UI.WebControls.Style CreateControlStyle()
{
// Create a new TableStyle instance based on ViewState values.
System.Web.UI.WebControls.TableStyle style = new System.Web.UI.WebControls.TableStyle(ViewState);
// Show the GridLines with no CellSpacing.
style.GridLines = System.Web.UI.WebControls.GridLines.Both;
style.CellSpacing = 0;
// Return the Style
return style;
}
}
}
Imports System.Web
Imports System.Security.Permissions
Namespace Samples.AspNet.VB.Controls
<AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class CustomDataGridCreateControlStyle
Inherits System.Web.UI.WebControls.DataGrid
Protected Overrides Function CreateControlStyle() As System.Web.UI.WebControls.Style
' Create a new TableStyle instance based on ViewState values.
Dim style As New System.Web.UI.WebControls.TableStyle(ViewState)
' Show the GridLines with no CellSpacing.
style.GridLines = System.Web.UI.WebControls.GridLines.Both
style.CellSpacing = 0
' Return the Style
Return style
End Function
End Class
End Namespace