DropDownList.SelectedIndex プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DropDownList.SelectedIndex プロパティの意味・解説 

DropDownList.SelectedIndex プロパティ

DropDownList コントロール内の選択された項目のインデックス取得または設定します

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Overrides Property
 SelectedIndex As Integer
Dim instance As DropDownList
Dim value As Integer

value = instance.SelectedIndex

instance.SelectedIndex = value
public override int SelectedIndex { get;
 set; }
/** @property */
public int get_SelectedIndex ()

/** @property */
public void set_SelectedIndex (int
 value)

プロパティ
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>
 
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からDropDownList.SelectedIndex プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からDropDownList.SelectedIndex プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からDropDownList.SelectedIndex プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「DropDownList.SelectedIndex プロパティ」の関連用語

DropDownList.SelectedIndex プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DropDownList.SelectedIndex プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS