CheckBox.OnCheckedChanged メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > CheckBox.OnCheckedChanged メソッドの意味・解説 

CheckBox.OnCheckedChanged メソッド

CheckBox コントロールの CheckedChanged イベント発生させます。これにより、イベント直接処理できます

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

Protected Overridable Sub
 OnCheckedChanged ( _
    e As EventArgs _
)
Dim e As EventArgs

Me.OnCheckedChanged(e)
protected virtual void OnCheckedChanged (
    EventArgs e
)
protected:
virtual void OnCheckedChanged (
    EventArgs^ e
)
protected void OnCheckedChanged (
    EventArgs e
)
protected function OnCheckedChanged (
    e : EventArgs
)

パラメータ

e

イベント データ格納している System.EventArgs。

解説解説
使用例使用例

CheckBox コントロールCheckedChanged イベントハンドラ指定およびコード化する方法次の例に示します

メモメモ

次のコード サンプルはシングルファイル コード モデル使用しており、分離コード ファイル直接コピーされ場合正常に動作しない可能性あります。各コード サンプルは、拡張子.aspx の空のテキスト ファイルコピーする必要がありますWeb フォームコード モデル詳細については、「ASP.NET Web ページコード モデル」を参照してください

<%@ Page Language="VB" AutoEventWireup="True"
 %>

<html>
<head>
 
   <script runat="server">
 
      Sub Check_Clicked(sender As Object,
 e As EventArgs) 

         ' Calculate the subtotal and display the result in currency
 format.
         ' Include tax if the check box is selected.
         Message.Text = CalculateTotal(checkbox1.Checked).ToString("c")

      End Sub

      Sub Page_Load(sender As Object,
 e As EventArgs)

         ' Display the subtotal without tax when the page is first loaded.
         If Not IsPostBack Then

            ' Calculate the subtotal and display the result in currency
 format.
            Message.Text = CalculateTotal(false).ToString("c")

         End If

      End Sub

      Function CalculateTotal(Taxable As Boolean)
 As Double 

         ' Calculate the subtotal for the example.
         Dim Result As Double
 = 1.99 + 2.99 + 3.99

         ' Add tax, if applicable.
         If(Taxable)

            Result += Result * 0.086
         
         End If

         Return Result 

      End Function
 
   </script>
 
</head>
 
<body>
 
   <form runat="server">
 
      <h3>CheckBox CheckedChanged Example</h3>

      Select whether to include tax in
 the subtotal.

      <br><br>

      <table border="1" cellpadding="5">

         <tr>

            <th colspan="2">

               Shopping cart

            </th>

         </tr>

         <tr>

            <td>

               Item 1

            </td>

            <td>

               $1.99

            </td>

         </tr>

         <tr>

            <td>

               Item 2

            </td>

            <td>

               $2.99

            </td>

         </tr>

         <tr>

            <td>

               Item 3

            </td>

            <td>

               $3.99

            </td>

         </tr>

         <tr>

            <td>

               <b>Subtotal</b>

            </td>

            <td>

               <asp:Label id="Message" runat="server"/>

            </td>

         </tr>

         <tr>

            <td colspan="2">

               <asp:CheckBox id="checkbox1" runat="server"
                    AutoPostBack="True"
                    Text="Include 8.6% sales tax"
                    TextAlign="Right"
                    OnCheckedChanged="Check_Clicked"/>

            </td>

         </tr>

      </table>
                   
   </form>
         
</body>

</html>

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

<html>
<head>
 
   <script runat="server">
 
      void Check_Clicked(Object sender, EventArgs e) 
      {

         // Calculate the subtotal and display the result in currency
 format.
         // Include tax if the check box is selected.
         Message.Text = CalculateTotal(checkbox1.Checked).ToString("c");

      }

      void Page_Load(Object sender, EventArgs e)
      {

         // Display the subtotal without tax when the page is first
 loaded.
         if(!IsPostBack)
         {

            // Calculate the subtotal and display the result in currency
 format.
            Message.Text = CalculateTotal(false).ToString("c");

         }

      }

      double CalculateTotal(bool Taxable)
      {

         // Calculate the subtotal for the example.
         double Result = 1.99 + 2.99 + 3.99;

         // Add tax, if applicable.
         if(Taxable)
         {
            Result += Result * 0.086;
         }

         return Result; 

      }
 
   </script>
 
</head>
 
<body>
 
   <form runat="server">
 
      <h3>CheckBox CheckedChanged Example</h3>

      Select whether to include tax in the subtotal.

      <br><br>

      <table border="1" cellpadding="5">

         <tr>

            <th colspan="2">

               Shopping cart

            </th>

         </tr>

         <tr>

            <td>

               Item 1

            </td>

            <td>

               $1.99

            </td>

         </tr>

         <tr>

            <td>

               Item 2

            </td>

            <td>

               $2.99

            </td>

         </tr>

         <tr>

            <td>

               Item 3

            </td>

            <td>

               $3.99

            </td>

         </tr>

         <tr>

            <td>

               <b>Subtotal</b>

            </td>

            <td>

               <asp:Label id="Message" runat="server"/>

            </td>

         </tr>

         <tr>

            <td colspan="2">

               <asp:CheckBox id="checkbox1" runat="server"
                    AutoPostBack="True"
                    Text="Include 8.6% sales tax"
                    TextAlign="Right"
                    OnCheckedChanged="Check_Clicked"/>

            </td>

         </tr>

      </table>
                   
   </form>
         
</body>

</html>

<%@ Page Language="VB" AutoEventWireup="True"
 %>

<html>
<head>
 
   <script runat="server">
 
      Sub Check_Clicked(sender As Object,
 e As EventArgs) 

         ' Calculate the subtotal and display the result in currency
 format.
         ' Include tax if the check box is selected.
         Message.Text = CalculateTotal(checkbox1.Checked).ToString("c")

      End Sub

      Sub Page_Load(sender As Object,
 e As EventArgs)

         ' Display the subtotal without tax when the page is first loaded.
         If Not IsPostBack Then

            ' Calculate the subtotal and display the result in 
            ' currency format.
            Message.Text = CalculateTotal(false).ToString("c")

         End If

         ' Manually register the event-handling method for the   
         ' CheckedChanged event of the CheckBox control.
         AddHandler checkbox1.CheckedChanged, AddressOf
 Check_Clicked

      End Sub

      Function CalculateTotal(Taxable As Boolean)
 As Double 

         ' Calculate the subtotal for the example.
         Dim Result As Double
 = 1.99 + 2.99 + 3.99

         ' Add tax, if applicable.
         If(Taxable)

            Result += Result * 0.086
         
         End If

         Return Result 

      End Function
 
   </script>
 
</head>
 
<body>
 
   <form runat="server">
 
      <h3>CheckBox CheckedChanged Example</h3>

      Select whether to include tax in
 the subtotal.

      <br><br>

      <table border="1" cellpadding="5">

         <tr>

            <th colspan="2">

               Shopping cart

            </th>

         </tr>

         <tr>

            <td>

               Item 1

            </td>

            <td>

               $1.99

            </td>

         </tr>

         <tr>

            <td>

               Item 2

            </td>

            <td>

               $2.99

            </td>

         </tr>

         <tr>

            <td>

               Item 3

            </td>

            <td>

               $3.99

            </td>

         </tr>

         <tr>

            <td>

               <b>Subtotal</b>

            </td>

            <td>

               <asp:Label id="Message" runat="server"/>

            </td>

         </tr>

         <tr>

            <td colspan="2">

               <asp:CheckBox id="checkbox1" runat="server"
                    AutoPostBack="True"
                    Text="Include 8.6% sales tax"
                    TextAlign="Right"
                    OnCheckedChanged="Check_Clicked"/>

            </td>

         </tr>

      </table>
                   
   </form>
         
</body>

</html>

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

<html>
<head>
 
   <script runat="server">
 
      void Check_Clicked(Object sender, EventArgs e) 
      {

         // Calculate the subtotal and display the result in currency
 format.
         // Include tax if the check box is selected.
         Message.Text = CalculateTotal(checkbox1.Checked).ToString("c");

      }

      void Page_Load(Object sender, EventArgs e)
      {

         // Display the subtotal without tax when the page is first
 loaded.
         if(!IsPostBack)
         {

            // Calculate the subtotal and display the result in 
            // currency format.
            Message.Text = CalculateTotal(false).ToString("c");

         }

         // Manually register the event-handling method for the   
         // CheckedChanged event of the CheckBox control.
         checkbox1.CheckedChanged += new EventHandler(this.Check_Clicked);

      }

      double CalculateTotal(bool Taxable)
      {

         // Calculate the subtotal for the example.
         double Result = 1.99 + 2.99 + 3.99;

         // Add tax, if applicable.
         if(Taxable)
         {
            Result += Result * 0.086;
         }

         return Result; 

      }
 
   </script>
 
</head>
 
<body>
 
   <form runat="server">
 
      <h3>CheckBox CheckedChanged Example</h3>

      Select whether to include tax in the subtotal.

      <br><br>

      <table border="1" cellpadding="5">

         <tr>

            <th colspan="2">

               Shopping cart

            </th>

         </tr>

         <tr>

            <td>

               Item 1

            </td>

            <td>

               $1.99

            </td>

         </tr>

         <tr>

            <td>

               Item 2

            </td>

            <td>

               $2.99

            </td>

         </tr>

         <tr>

            <td>

               Item 3

            </td>

            <td>

               $3.99

            </td>

         </tr>

         <tr>

            <td>

               <b>Subtotal</b>

            </td>

            <td>

               <asp:Label id="Message" runat="server"/>

            </td>

         </tr>

         <tr>

            <td colspan="2">

               <asp:CheckBox id="checkbox1" runat="server"
                    AutoPostBack="True"
                    Text="Include 8.6% sales tax"
                    TextAlign="Right"/>

            </td>

         </tr>

      </table>
                   
   </form>
         
</body>

</html>

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

CheckBox.OnCheckedChanged メソッド

CheckedChanged イベント発生させます

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Protected Overridable Sub
 OnCheckedChanged ( _
    e As EventArgs _
)
Dim e As EventArgs

Me.OnCheckedChanged(e)
protected virtual void OnCheckedChanged (
    EventArgs e
)
protected:
virtual void OnCheckedChanged (
    EventArgs^ e
)
protected void OnCheckedChanged (
    EventArgs e
)
protected function OnCheckedChanged (
    e : EventArgs
)

パラメータ

e

イベント データ格納している EventArgs。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

CheckBox.OnCheckedChanged メソッドのお隣キーワード
検索ランキング

   

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



CheckBox.OnCheckedChanged メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS