Bagikan melalui


Table.GridLines Properti

Definisi

Mendapatkan atau mengatur gaya garis kisi untuk ditampilkan dalam Table kontrol.

public:
 virtual property System::Web::UI::WebControls::GridLines GridLines { System::Web::UI::WebControls::GridLines get(); void set(System::Web::UI::WebControls::GridLines value); };
[System.ComponentModel.Bindable(true)]
public virtual System.Web.UI.WebControls.GridLines GridLines { get; set; }
public virtual System.Web.UI.WebControls.GridLines GridLines { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.GridLines : System.Web.UI.WebControls.GridLines with get, set
member this.GridLines : System.Web.UI.WebControls.GridLines with get, set
Public Overridable Property GridLines As GridLines

Nilai Properti

Salah GridLines satu nilai enumerasi. Nilai defaultnya adalah None.

Atribut

Contoh

Contoh berikut menunjukkan cara menggunakan GridLines properti untuk menentukan gaya garis kisi.

Catatan

Sampel kode berikut menggunakan model kode file tunggal dan mungkin tidak berfungsi dengan benar jika disalin langsung ke file code-behind. Sampel kode ini harus disalin ke dalam file teks kosong yang memiliki ekstensi .aspx. Untuk informasi selengkapnya tentang model kode Formulir Web, lihat Model Kode Halaman Formulir Web ASP.NET.

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    private void Page_Load(Object sender, EventArgs e)
    {
        // Generate rows and cells.    
        int numrows = 5;
        int numcells = 4;
            
        for(int j=0; j<=numrows - 1; j++)
        {
            TableRow rw = new TableRow();
                
            for(int i=0; i <= numcells - 1; i++)
            {
               TableCell cel = new TableCell();
               cel.Controls.Add(new LiteralControl(
                   String.Format("row {0}, cell {1}", j, i)));
               rw.Cells.Add(cel);
            }
                
            Table1.Rows.Add(rw);
        }
    }

    private void Button_Click(Object sender, EventArgs e)
    { 
        Table1.GridLines = (GridLines)DropDown1.SelectedIndex;
    }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <h3>Table GridLines Example</h3>

    <asp:Table id="Table1" 
        BorderColor="black" 
        BorderWidth="1" 
        GridLines="Both" 
        runat="server" />

    <br />GridLines:

    <asp:DropDownList id="DropDown1" runat="server">
        <asp:ListItem Value="0">None</asp:ListItem>
        <asp:ListItem Value="1">Horizontal</asp:ListItem>
        <asp:ListItem Value="2">Vertical</asp:ListItem>
        <asp:ListItem Value="3">Both</asp:ListItem>
    </asp:DropDownList><br />

    <asp:button id="Button1"
        Text="Display Table"
        OnClick="Button_Click" 
        runat="server" />

    </div>
    </form>
</body>
</html>
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    Private Sub Page_Load(sender As Object, e As EventArgs) 
        ' Generate rows and cells.

        Dim numrows As Integer = 5
        Dim numcells As Integer = 4

        Dim i As Integer
        Dim j As Integer

        For j = 0 to numrows - 1
            Dim r As TableRow = new TableRow()
                
            For i = 0 to numcells - 1
                Dim c As TableCell = new TableCell()
                c.Controls.Add(New LiteralControl("row " & j.ToString() & _ 
                              ", cell " & i.ToString()))
                r.Cells.Add(c)
            Next ' i

            Table1.Rows.Add(r)
        Next ' j
    End Sub

    Private Sub Button_Click(sender As Object, e As EventArgs) 
        Table1.GridLines = CType(DropDown1.SelectedIndex, GridLines)
    End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    <h3>Table GridLines Example</h3>

    <asp:Table id="Table1" 
        BorderColor="black" 
        BorderWidth="1" 
        GridLines="Both" 
        runat="server" />

    <br />GridLines:

    <asp:DropDownList id="DropDown1" runat="server">
        <asp:ListItem Value="0">None</asp:ListItem>
        <asp:ListItem Value="1">Horizontal</asp:ListItem>
        <asp:ListItem Value="2">Vertical</asp:ListItem>
        <asp:ListItem Value="3">Both</asp:ListItem>
    </asp:DropDownList><br />

    <asp:button id="Button1"
        Text="Display Table"
        OnClick="Button_Click" 
        runat="server" />

    </div>
    </form>
</body>
</html>

Keterangan

GridLines Gunakan properti untuk menentukan batas sel mana yang ditampilkan dalam Table kontrol. Tabel berikut ini mencantumkan gaya garis kisi yang berbeda.

Nilai GridLine Deskripsi
None Tidak ada batas sel yang ditampilkan.
Horizontal Hanya batas sel horizontal yang ditampilkan.
Vertical Hanya batas sel vertikal yang ditampilkan.
Both Batas sel horizontal dan vertikal ditampilkan.

Berlaku untuk

Lihat juga