BulletStyle 列舉

定義

指定可以套用至 BulletedList 控制項中之清單項目的項目符號樣式。Specifies the bullet styles you can apply to list items in a BulletedList control.

public enum class BulletStyle
public enum BulletStyle
type BulletStyle = 
Public Enum BulletStyle
繼承
BulletStyle

欄位

Circle 7

項目符號樣式為空心圓形。The bullet style is an empty circle shape.

CustomImage 9

項目符號樣式為自訂影像。The bullet style is a custom image.

Disc 6

項目符號樣式為實心圓形。The bullet style is a filled circle shape.

LowerAlpha 2

項目符號樣式為小寫字母 (a、b、c...)。The bullet style is a lowercase letter (a, b, c, ...).

LowerRoman 4

項目符號樣式為小寫羅馬數字 (i、ii、iii...)。The bullet style is a lowercase Roman numeral (i, ii, iii, ...).

NotSet 0

項目符號樣式未設定。The bullet style is not set. 呈現 BulletedList 控制項的瀏覽器將決定要顯示的項目符號樣式。The browser that renders the BulletedList control will determine the bullet style to display.

Numbered 1

項目符號樣式為數字 (1、2、3...)。The bullet style is a number (1, 2, 3, ...).

Square 8

項目符號樣式為實心方形。The bullet style is a filled square shape.

UpperAlpha 3

項目符號樣式為大寫字母 (A、B、C...)。The bullet style is an uppercase letter (A, B, C, ...).

UpperRoman 5

項目符號樣式為大寫羅馬數字 (I、II、III...)。The bullet style is an uppercase Roman numeral (I, II, III, ...).

範例

下列範例示範如何建立 BulletedList 控制項。The following example demonstrates how to create a BulletedList control. ListBox控制項會填入所有可用的 BulletStyle 列舉值。A ListBox control is populated with all available BulletStyle enumeration values. 專案符號樣式會根據使用者從清單方塊中選取的樣式而變更。The bullet style changes based on the style that the user selects from the list box.


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

<!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 runat="server">
    <title>
            BulletStyle Example</title>
<script runat="server">       
        protected void Index_Changed(object sender, EventArgs e)
        {
            // Change the message displayed, based on 
            // the style selected from the list box.
            if (BulletStylesListBox.SelectedIndex > -1)
            {
                Message.Text = "You selected bullet style: " +
                    BulletStylesListBox.SelectedItem.Text;
            }

            // Change the bullet style used, based on 
            // the style selected from the list box.
            switch (BulletStylesListBox.SelectedIndex)
            {
                case 0:
                    ItemsBulletedList.BulletStyle = BulletStyle.Numbered;
                    break;
                case 1:
                    ItemsBulletedList.BulletStyle = BulletStyle.LowerAlpha;
                    break;
                case 2:
                    ItemsBulletedList.BulletStyle = BulletStyle.UpperAlpha;
                    break;
                case 3:
                    ItemsBulletedList.BulletStyle = BulletStyle.LowerRoman;
                    break;
                case 4:
                    ItemsBulletedList.BulletStyle = BulletStyle.UpperRoman;
                    break;
                case 5:
                    ItemsBulletedList.BulletStyle = BulletStyle.Disc;
                    break;
                case 6:
                    ItemsBulletedList.BulletStyle = BulletStyle.Circle;
                    break;
                case 7:
                    ItemsBulletedList.BulletStyle = BulletStyle.Square;
                    break;
                case 8:
                    ItemsBulletedList.BulletStyle = BulletStyle.CustomImage;
                    // Specify the path to the custom image to use for the bullet.
                    ItemsBulletedList.BulletImageUrl = "Images/image1.jpg";
                    break;
                case 9:
                    Message.Text = "You selected NotSet. The browser will determine the bullet style.";
                    break;
                default:
                    throw new Exception("You did not select a valid bullet style.");
            }

        }
</script>

</head>
<body>
    <form id="form1" runat="server">
        <h3>
            BulletStyle Example</h3>
        <asp:BulletedList ID="ItemsBulletedList" DisplayMode="Text" BulletStyle="NotSet"
            runat="server">
            <asp:ListItem Value="0">Coho Winery</asp:ListItem>
            <asp:ListItem Value="1">Contoso, Ltd.</asp:ListItem>
            <asp:ListItem Value="2">Tailspin Toys</asp:ListItem>
        </asp:BulletedList>
        <hr />
        <h4>
            Select a bullet type:</h4>
        <asp:ListBox ID="BulletStylesListBox" SelectionMode="Single" Rows="1" OnSelectedIndexChanged="Index_Changed"
            AutoPostBack="True" runat="server">
            <asp:ListItem Value="Numbered">Numbered</asp:ListItem>
            <asp:ListItem Value="LowerAlpha">LowerAlpha</asp:ListItem>
            <asp:ListItem Value="UpperAlpha">UpperAlpha</asp:ListItem>
            <asp:ListItem Value="LowerRoman">LowerRoman</asp:ListItem>
            <asp:ListItem Value="UpperRoman">UpperRoman</asp:ListItem>
            <asp:ListItem>Disc</asp:ListItem>
            <asp:ListItem>Circle</asp:ListItem>
            <asp:ListItem>Square</asp:ListItem>
            <asp:ListItem>CustomImage</asp:ListItem>
            <asp:ListItem Value="NotSet">NotSet</asp:ListItem>
        </asp:ListBox>
        <hr />
        <asp:Label ID="Message" runat="server" AssociatedControlID="BulletStylesListBox" />
    </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">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>BulletStyle Example</title>
<script runat="server">       
        Sub Index_Changed(ByVal sender As Object, ByVal e As System.EventArgs)
            ' Change the message displayed, based on 
            ' the style selected from the list box.
            If BulletStylesListBox.SelectedIndex > -1 Then
                Message.Text = "You selected bullet style: " & BulletStylesListBox.SelectedItem.Text
            End If

            ' Change the bullet style used, based on 
            ' the style selected from the list box.
            Select Case (BulletStylesListBox.SelectedIndex)
                Case 0
                    ItemsBulletedList.BulletStyle = BulletStyle.Numbered
                Case 1
                    ItemsBulletedList.BulletStyle = BulletStyle.LowerAlpha
                Case 2
                    ItemsBulletedList.BulletStyle = BulletStyle.UpperAlpha
                Case 3
                    ItemsBulletedList.BulletStyle = BulletStyle.LowerRoman
                Case 4
                    ItemsBulletedList.BulletStyle = BulletStyle.UpperRoman
                Case 5
                    ItemsBulletedList.BulletStyle = BulletStyle.Disc
                Case 6
                    ItemsBulletedList.BulletStyle = BulletStyle.Circle
                Case 7
                    ItemsBulletedList.BulletStyle = BulletStyle.Square
                Case 8
                    ItemsBulletedList.BulletStyle = BulletStyle.CustomImage
                    ' Specify the path to the custom image to use for the bullet.
                    ItemsBulletedList.BulletImageUrl = "Images/image1.jpg"
                Case 9
                    Message.Text = "You selected NotSet. The browser will determine the bullet style."
                Case Else
                    Throw New Exception("You did not select a valid bullet style.")
            End Select

        End Sub

</script>

</head>
<body>
    <form id="form1" runat="server"> 

        <h3>BulletStyle Example</h3>

        <asp:BulletedList id="ItemsBulletedList"             
            DisplayMode="Text" 
            BulletStyle="NotSet"
            runat="server">    
                <asp:ListItem Value="0">Coho Winery</asp:ListItem>
                <asp:ListItem Value="1">Contoso, Ltd.</asp:ListItem>
                <asp:ListItem Value="2">Tailspin Toys</asp:ListItem>
            </asp:BulletedList>        

            <hr />

        <h4>Select a bullet type:</h4>        
        <asp:ListBox id="BulletStylesListBox" 
            SelectionMode="Single"
            Rows="1" 
            OnSelectedIndexChanged="Index_Changed"
            AutoPostBack="True"
            runat="server">         
                <asp:ListItem Value="Numbered">Numbered</asp:ListItem>
                <asp:ListItem Value="LowerAlpha">LowerAlpha</asp:ListItem>
                <asp:ListItem Value="UpperAlpha">UpperAlpha</asp:ListItem>
                <asp:ListItem Value="LowerRoman">LowerRoman</asp:ListItem>
                <asp:ListItem Value="UpperRoman">UpperRoman</asp:ListItem>
                <asp:ListItem>Disc</asp:ListItem>
                <asp:ListItem>Circle</asp:ListItem>
                <asp:ListItem>Square</asp:ListItem>
                <asp:ListItem>CustomImage</asp:ListItem>       
                <asp:ListItem Value="NotSet">NotSet</asp:ListItem>
        </asp:ListBox>        
            
        <hr />

        <asp:Label id="Message" 
            runat="server"
            AssociatedControlID="BulletStylesListBox"/>            
                  
   </form>
</body>
</html>

備註

列舉型別 BulletStyle (enumeration)表示可以套用至控制項中清單專案的專案符號樣式 BulletedListThe BulletStyle enumeration represents the bullet styles that you can apply to the list items in a BulletedList control. BulletStyle屬性會使用這些列舉值來設定控制項中的專案符號樣式 BulletedListThe BulletStyle property uses these enumeration values to set the bullet styles in a BulletedList control. 例如,如果您將屬性設定 BulletStyleDisc ,則控制項中的每個清單專案 BulletedList 都會在清單專案的內容前面呈現填滿的圓形,如下所示:For example, if you set the BulletStyle property to Disc, each list item in a BulletedList control will render a filled circle preceding the content of the list item as follows:

  • 清單項目 1List Item 1

  • 清單項目 2List Item 2

  • 清單項目 3List Item 3

指定 CustomImage 專案符號樣式可讓您為專案符號提供自己的影像。Specifying the CustomImage bullet style allows you to supply your own image for the bullet. 如果您指定 CustomImage 專案符號樣式,您也必須將 BulletImageUrl 屬性設定為要使用的自訂影像 URL。If you specify the CustomImage bullet style, you must also set the BulletImageUrl property to the URL of the custom image to use.

如果您指定 NotSet ,則會在其中呈現控制項的瀏覽器會決定要顯示在控制項中清單專案的專案符號樣式 BulletedListIf you specify NotSet, the browser in which the control is rendered will determine the bullet style to display with the list items in the BulletedList control.

適用於

另請參閱