DropDownList.SelectedIndex プロパティ
アセンブリ: System.Web (system.web.dll 内)

Dim instance As DropDownList Dim value As Integer value = instance.SelectedIndex instance.SelectedIndex = value
/** @property */ public int get_SelectedIndex () /** @property */ public void set_SelectedIndex (int value)
public override function get SelectedIndex () : int public override function set SelectedIndex (value : int)
DropDownList コントロール内の選択された項目のインデックス。既定値は 0 であり、この場合はリストの最初の項目を選択します。

SelectedIndex プロパティを使用して、DropDownList コントロールから選択した項目のインデックスをプログラムにより指定または確認します。DropDownList コントロールの項目は常に 1 つ選択されます。リスト内のすべて項目を同時に選択解除することはできません。
![]() |
---|
DropDownList コントロールの項目のインデックス番号は 0 から始まります。 |

SelectedIndex プロパティを使用して、DropDownList コントロール内の選択されている項目を確認する方法を次のコード例に示します。
<%@ Page Language="VB" AutoEventWireup="True" %> <html> <script runat="server" > Sub Selection_Change(sender As Object, e As EventArgs) ' Set the title format based on the value selected from the ' DropDownList control. The SelectedIndex property can be used ' to determine an enumeration value. Simply cast the value to ' the appropriate enumeration type. Note that the value might ' need to be adjusted if the enumeration type is not zero-based. Calendar1.TitleFormat = CType(ModeList.SelectedIndex, TitleFormat) End Sub </script> <body> <form runat="server"> <h3> DropDownList SelectedIndex Example </h3> Choose the title format. <br><br> <asp:Calendar id="Calendar1" ShowGridLines="True" ShowTitle="True" runat="server"/> <br><br> <table cellpadding="5"> <tr> <td> Format: </td> </tr> <tr> <td> <asp:DropDownList id="ModeList" AutoPostBack="True" OnSelectedIndexChanged="Selection_Change" runat="server"> <asp:ListItem> Month </asp:ListItem> <asp:ListItem Selected="True"> MonthYear </asp:ListItem> </asp:DropDownList> </td> </tr> </form> </body> </html>
<%@ Page Language="C#" AutoEventWireup="True" %> <html> <script runat="server" > void Selection_Change(Object sender, EventArgs e) { // Set the title format based on the value selected from the // DropDownList control. The SelectedIndex property can be used // to determine an enumeration value. Simply cast the value to // the appropriate enumeration type. Note that the value might // need to be adjusted if the enumeration type is not zero-based. Calendar1.TitleFormat = (TitleFormat)ModeList.SelectedIndex; } </script> <body> <form runat="server"> <h3> DropDownList SelectedIndex Example </h3> Choose the title format. <br><br> <asp:Calendar id="Calendar1" ShowGridLines="True" ShowTitle="True" runat="server"/> <br><br> <table cellpadding="5"> <tr> <td> Format: </td> </tr> <tr> <td> <asp:DropDownList id="ModeList" AutoPostBack="True" OnSelectedIndexChanged="Selection_Change" runat="server"> <asp:ListItem> Month </asp:ListItem> <asp:ListItem Selected="True"> MonthYear </asp:ListItem> </asp:DropDownList> </td> </tr> </form> </body> </html>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からDropDownList.SelectedIndex プロパティを検索する場合は、下記のリンクをクリックしてください。

- DropDownList.SelectedIndex プロパティのページへのリンク