ListView.AfterLabelEdit イベントとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ListView.AfterLabelEdit イベントの意味・解説 

ListView.AfterLabelEdit イベント

項目のラベルユーザーによって編集される発生します

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

Public Event AfterLabelEdit As
 LabelEditEventHandler
Dim instance As ListView
Dim handler As LabelEditEventHandler

AddHandler instance.AfterLabelEdit, handler
public event LabelEditEventHandler AfterLabelEdit
public:
event LabelEditEventHandler^ AfterLabelEdit {
    void add (LabelEditEventHandler^ value);
    void remove (LabelEditEventHandler^ value);
}
/** @event */
public void add_AfterLabelEdit (LabelEditEventHandler
 value)

/** @event */
public void remove_AfterLabelEdit (LabelEditEventHandler
 value)
JScript では、イベント使用できますが、新規に宣言することはできません。
解説解説
使用例使用例

AfterLabelEdit イベント使用して新しく編集するラベル文字アルファベット制限する方法次のコード例示します。この例では、ASCIIEncoding クラス使用して新しレベルの各文字ASCII 文字コード取得してます。この文字数字を表す ASCII コード場合新しラベルは項目には適用できません。この例では、フォーム上に ListView コントロール作成され、そのコントロールに項目が追加されている必要がありますまた、AfterLabelEdit イベントが、この例で定義されているイベント ハンドラ接続されている必要もありますASCIIEncoding クラス使用するには、ファイルSystem.Text 名前空間含まれている必要があります

Private Sub MyListView_AfterLabelEdit(ByVal
 sender As Object, ByVal
 e As System.Windows.Forms.LabelEditEventArgs) Handles listView1.AfterLabelEdit

   ' Determine if label is changed by checking to see if it is equal
 to Nothing.
   If e.Label = Nothing Then
      Return
   End If
   ' ASCIIEncoding is used to determine if a number character has been
 entered.
   Dim AE As New ASCIIEncoding()
   ' Convert the new label to a character array.
   Dim temp As Char() =
 e.Label.ToCharArray()

   ' Check each character in the new label to determine if it is a number.
   Dim x As Integer
   For x = 0 To temp.Length - 1
      ' Encode the character from the character array to its ASCII code.
      Dim bc As Byte() =
 AE.GetBytes(temp(x).ToString())

      ' Determine if the ASCII code is within the valid range of numerical
 values.
      If bc(0) > 47 And bc(0) < 58 Then
         ' Cancel the event and return the lable to its original state.
         e.CancelEdit = True
         ' Display a MessageBox alerting the user that numbers are not
 allowed.
         MessageBox.Show("The text for the item cannot contain
 numerical values.")
         ' Break out of the loop and exit.
         Return
      End If
   Next x
End Sub
private void MyListView_AfterLabelEdit(object
 sender, System.Windows.Forms.LabelEditEventArgs e)
{
 
   // Determine if label is changed by checking for null.
   if (e.Label == null)
      return;

   // ASCIIEncoding is used to determine if a number character has been
 entered.
   ASCIIEncoding AE = new ASCIIEncoding();
   // Convert the new label to a character array.
   char[] temp = e.Label.ToCharArray();

   // Check each character in the new label to determine if it is a
 number.
   for(int x=0; x < temp.Length; x++)
   {
      // Encode the character from the character array to its ASCII
 code.
      byte[] bc = AE.GetBytes(temp[x].ToString());
   
      // Determine if the ASCII code is within the valid range of numerical
 values.
      if(bc[0] > 47 && bc[0] < 58)
      {
         // Cancel the event and return the lable to its original state.
         e.CancelEdit = true;
         // Display a MessageBox alerting the user that numbers are
 not allowed.
         MessageBox.Show ("The text for the item cannot contain
 numerical values.");
         // Break out of the loop and exit.
         return;
      }
   }
}
private:
   void MyListView_AfterLabelEdit( Object^ /*sender*/, System::Windows::Forms::LabelEditEventArgs^
 e )
   {
      // Determine if label is changed by checking for 0.
      if ( e->Label == nullptr )
               return;

      // ASCIIEncoding is used to determine if a number character has been
 entered.
      ASCIIEncoding^ AE = gcnew ASCIIEncoding;

      // Convert the new label to a character array.
      array<Char>^temp = e->Label->ToCharArray();

      // Check each character in the new label to determine if it is a
 number.
      for ( int x = 0; x < temp->Length;
 x++ )
      {
         // Encode the character from the character array to its ASCII
 code.
         array<Byte>^bc = AE->GetBytes( temp[ x ].ToString() );

         // Determine if the ASCII code is within the valid range of numerical
 values.
         if ( bc[ 0 ] > 47 && bc[ 0 ] < 58 )
         {
            // Cancel the event and return the lable to its original
 state.
            e->CancelEdit = true;

            // Display a MessageBox alerting the user that numbers are
 not allowed.
            MessageBox::Show( "The text for the item cannot
 contain numerical values." );

            // Break out of the loop and exit.
            return;
         }
      }
   }
private void MyListView_AfterLabelEdit(Object
 sender, 
    System.Windows.Forms.LabelEditEventArgs e)
{
    // Determine if label is changed by checking for null.
    if (e.get_Label() == null) {
        return;
    }

    // ASCIIEncoding is used to determine 
    // if a number character has been entered.
    ASCIIEncoding ae = new ASCIIEncoding();

    // Convert the new label to a character array.
    char temp[] = e.get_Label().ToCharArray();

    // Check each character in the new label to determine if it is a
 number.
    for (int x = 0; x < temp.get_Length();
 x++) {
        // Encode the character from the character array to its ASCII
 code.
        ubyte bc[] = ae.GetBytes(temp.get_Item(x).ToString());

        // Determine if the ASCII code is within the valid range 
        // of numerical values.
        if (Convert.ToInt32(bc.get_Item(0)) > 47 
            && Convert.ToInt32(bc.get_Item(0)) < 58) {
            // Cancel the event and return the lable to its original
 state.
            e.set_CancelEdit(true);

            // Display a MessageBox alerting the user that 
            // numbers are not allowed.
            MessageBox.Show("The text for the item cannot
 contain "
                + "numerical values.");

            // Break out of the loop and exit.
            return;
        }
    }
} //MyListView_AfterLabelEdit
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ListView クラス
ListView メンバ
System.Windows.Forms 名前空間
OnAfterLabelEdit
BeforeLabelEdit
LabelEditEventHandler デリゲート
ListView.LabelEdit プロパティ


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

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

辞書ショートカット

すべての辞書の索引

「ListView.AfterLabelEdit イベント」の関連用語

ListView.AfterLabelEdit イベントのお隣キーワード
検索ランキング

   

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



ListView.AfterLabelEdit イベントのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS