DataGridViewCellParsingEventArgsとは? わかりやすく解説

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

DataGridViewCellParsingEventArgs クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

DataGridView コントロールの CellParsing イベントデータ提供します

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

Public Class DataGridViewCellParsingEventArgs
    Inherits ConvertEventArgs
Dim instance As DataGridViewCellParsingEventArgs
public class DataGridViewCellParsingEventArgs
 : ConvertEventArgs
public ref class DataGridViewCellParsingEventArgs
 : public ConvertEventArgs
public class DataGridViewCellParsingEventArgs
 extends ConvertEventArgs
public class DataGridViewCellParsingEventArgs
 extends ConvertEventArgs
解説解説

ユーザー指定した値から、セルValueType プロパティ指定された型の値へカスタム変換を行うには、CellParsing イベント処理します

CellParsing イベント処理する場合、値を自分変換するか、既定変換カスタマイズできます。たとえば、セルの ParseFormattedValue メソッド選択したコンバータ使用して、値を自分変更できます。または、既定の型コンバータに値を解析させる一方でセルの InheritedStyle プロパティ使用して初期化される DataGridViewCellParsingEventArgs.InheritedCellStyle プロパティによって返されオブジェクトの NullValue、DataSourceNullValue、および FormatProvider の各プロパティ変更できます

値を自分変換する場合は、ConvertEventArgs.Value プロパティ書式設定された最初の値を、セルValueType プロパティ指定された型の変換後の値に置換します。解析不要になったことを指定するには、DataGridViewCellParsingEventArgs.ParsingApplied プロパティtrue設定します

イベント ハンドラ完了したときに、Valuenull 参照 (Visual Basic では Nothing) になっているか、正しい型ではない場合、または ParsingApplied プロパティfalse場合Value は、セルParseFormattedValue メソッド既定の型コンバータ使用して解析されます。このメソッド既定実装は、渡されセル スタイルNullValueDataSourceNullValue、および FormatProvider の各プロパティ使用して値を解析します。値が NullValueない場合、その値は、渡されFormatProvider プロパティと型コンバータ使用して解析されます。

セル値を、表示合わせて書式設定された値に変換するときにカスタマイズ適用するには、CellFormatting イベント処理します

イベント処理詳細については、「イベント利用」を参照してください

使用例使用例

DataGridViewCellParsingEventArgs使用して日付エントリの有効性確認するコード例次に示します

' Handling CellParsing allows one to accept user input, then map it
 to a different
' internal representation.
Private Sub dataGridView1_CellParsing(ByVal
 sender As Object, _
    ByVal e As DataGridViewCellParsingEventArgs)
 _
    Handles dataGridView1.CellParsing

    If Me.dataGridView1.Columns(e.ColumnIndex).Name
 = _
        "Release Date" Then
        If e IsNot Nothing Then
            If e.Value IsNot Nothing Then
                Try
                    ' Map what the user typed into UTC.
                    e.Value = _
                    DateTime.Parse(e.Value.ToString()).ToUniversalTime()
                    ' Set the ParsingApplied property to 
                    ' Show the event is handled.
                    e.ParsingApplied = True

                Catch ex As FormatException
                    ' Set to false in case another CellParsing handler
                    ' wants to try to parse this DataGridViewCellParsingEventArgs
 instance.
                    e.ParsingApplied = False
                End Try
            End If
        End If
    End If
End Sub
// Handling CellParsing allows one to accept user input, then map it
 to a different
// internal representation.
private void dataGridView1_CellParsing(object
 sender, DataGridViewCellParsingEventArgs e)
{
    if (this.dataGridView1.Columns[e.ColumnIndex].Name
 == "Release Date")
    {
        if (e != null)
        {
            if (e.Value != null)
            {
                try
                {
                    // Map what the user typed into UTC.
                    e.Value = DateTime.Parse(e.Value.ToString()).ToUniversalTime();
                    // Set the ParsingApplied property to 
                    // Show the event is handled.
                    e.ParsingApplied = true;

                }
                catch (FormatException)
                {
                    // Set to false in case another CellParsing handler
                    // wants to try to parse this DataGridViewCellParsingEventArgs
 instance.
                    e.ParsingApplied = false;
                }
            }
        }
    }
}
// Handling CellParsing allows one to accept user input, then map it
 to a different
// internal representation.
void dataGridView1_CellParsing( Object^ /*sender*/, DataGridViewCellParsingEventArgs^
 e )
{
   if ( this->dataGridView1->Columns[
 e->ColumnIndex ]->Name->Equals( "Release Date" ) )
   {
      if ( e != nullptr )
      {
         if ( e->Value != nullptr )
         {
            try
            {
               // Map what the user typed into UTC.
               e->Value = DateTime::Parse( e->Value->ToString() ).ToUniversalTime();

               // Set the ParsingApplied property to 
               // Show the event is handled.
               e->ParsingApplied = true;
            }
            catch ( FormatException^ /*ex*/ ) 
            {
               // Set to false in case another CellParsing handler
               // wants to try to parse this DataGridViewCellParsingEventArgs
 instance.
               e->ParsingApplied = false;
            }
         }
      }
   }
}
継承階層継承階層
System.Object
   System.EventArgs
     System.Windows.Forms.ConvertEventArgs
      System.Windows.Forms.DataGridViewCellParsingEventArgs
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGridViewCellParsingEventArgs メンバ
System.Windows.Forms 名前空間
DataGridView クラス
DataGridView.CellParsing イベント
DataGridView.OnCellParsing
DataGridView.CellFormatting イベント
DataGridView.EditMode プロパティ
DataGridViewCell.ValueType プロパティ
DataGridViewCell.InheritedStyle プロパティ
DataGridViewCell.ParseFormattedValue
DataGridViewCellParsingEventHandler
ConvertEventArgs.Value プロパティ
InheritedCellStyle
ParsingApplied
DataGridViewCellStyle
DataGridViewCellStyle.NullValue
DataGridViewCellStyle.Format
DataGridViewCellStyle.FormatProvider

DataGridViewCellParsingEventArgs コンストラクタ

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

DataGridViewCellParsingEventArgs クラス新しインスタンス初期化します。

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

Public Sub New ( _
    rowIndex As Integer, _
    columnIndex As Integer, _
    value As Object, _
    desiredType As Type, _
    inheritedCellStyle As DataGridViewCellStyle _
)
Dim rowIndex As Integer
Dim columnIndex As Integer
Dim value As Object
Dim desiredType As Type
Dim inheritedCellStyle As DataGridViewCellStyle

Dim instance As New DataGridViewCellParsingEventArgs(rowIndex,
 columnIndex, value, desiredType, inheritedCellStyle)
public DataGridViewCellParsingEventArgs (
    int rowIndex,
    int columnIndex,
    Object value,
    Type desiredType,
    DataGridViewCellStyle inheritedCellStyle
)
public:
DataGridViewCellParsingEventArgs (
    int rowIndex, 
    int columnIndex, 
    Object^ value, 
    Type^ desiredType, 
    DataGridViewCellStyle^ inheritedCellStyle
)
public DataGridViewCellParsingEventArgs (
    int rowIndex, 
    int columnIndex, 
    Object value, 
    Type desiredType, 
    DataGridViewCellStyle inheritedCellStyle
)
public function DataGridViewCellParsingEventArgs
 (
    rowIndex : int, 
    columnIndex : int, 
    value : Object, 
    desiredType : Type, 
    inheritedCellStyle : DataGridViewCellStyle
)

パラメータ

rowIndex

変更されセルの行インデックス

columnIndex

変更されセルの列インデックス

value

新しい値。

desiredType

新しい値の型。

inheritedCellStyle

変更されセル適用されスタイル

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGridViewCellParsingEventArgs クラス
DataGridViewCellParsingEventArgs メンバ
System.Windows.Forms 名前空間
DataGridView クラス
DataGridView.CellParsing イベント
DataGridView.OnCellParsing
DataGridViewCell.ValueType プロパティ
ConvertEventArgs.Value プロパティ
InheritedCellStyle
DataGridViewCellStyle

DataGridViewCellParsingEventArgs プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ ColumnIndex 解析を必要とするセル データの列インデックス取得します
パブリック プロパティ DesiredType  必要な値のデータ型取得します。 ( ConvertEventArgs から継承されます。)
パブリック プロパティ InheritedCellStyle 編集されセル適用されるスタイル取得または設定します
パブリック プロパティ ParsingApplied セルの値が正常に解析されたかどうかを示す値を取得または設定します
パブリック プロパティ RowIndex 解析を必要とするセルの行インデックス取得します
パブリック プロパティ Value  ConvertEventArgs の値を取得または設定します。 ( ConvertEventArgs から継承されます。)
参照参照

関連項目

DataGridViewCellParsingEventArgs クラス
System.Windows.Forms 名前空間
DataGridView クラス
DataGridView.CellParsing イベント
DataGridView.OnCellParsing
DataGridView.CellFormatting イベント
DataGridView.EditMode プロパティ
DataGridViewCell.ValueType プロパティ
DataGridViewCell.InheritedStyle プロパティ
DataGridViewCell.ParseFormattedValue
DataGridViewCellParsingEventHandler
ConvertEventArgs.Value プロパティ
InheritedCellStyle
ParsingApplied
DataGridViewCellStyle
DataGridViewCellStyle.NullValue
DataGridViewCellStyle.Format
DataGridViewCellStyle.FormatProvider

DataGridViewCellParsingEventArgs メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
参照参照

関連項目

DataGridViewCellParsingEventArgs クラス
System.Windows.Forms 名前空間
DataGridView クラス
DataGridView.CellParsing イベント
DataGridView.OnCellParsing
DataGridView.CellFormatting イベント
DataGridView.EditMode プロパティ
DataGridViewCell.ValueType プロパティ
DataGridViewCell.InheritedStyle プロパティ
DataGridViewCell.ParseFormattedValue
DataGridViewCellParsingEventHandler
ConvertEventArgs.Value プロパティ
InheritedCellStyle
ParsingApplied
DataGridViewCellStyle
DataGridViewCellStyle.NullValue
DataGridViewCellStyle.Format
DataGridViewCellStyle.FormatProvider

DataGridViewCellParsingEventArgs メンバ

DataGridView コントロールの CellParsing イベントデータ提供します

DataGridViewCellParsingEventArgs データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド DataGridViewCellParsingEventArgs DataGridViewCellParsingEventArgs クラス新しインスタンス初期化します。
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ ColumnIndex 解析を必要とするセル データの列インデックス取得します
パブリック プロパティ DesiredType  必要な値のデータ型取得します。(ConvertEventArgs から継承されます。)
パブリック プロパティ InheritedCellStyle 編集されセル適用されるスタイル取得または設定します
パブリック プロパティ ParsingApplied セルの値が正常に解析されたかどうかを示す値を取得または設定します
パブリック プロパティ RowIndex 解析を必要とするセルの行インデックス取得します
パブリック プロパティ Value  ConvertEventArgs の値を取得または設定します。(ConvertEventArgs から継承されます。)
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

DataGridViewCellParsingEventArgs クラス
System.Windows.Forms 名前空間
DataGridView クラス
DataGridView.CellParsing イベント
DataGridView.OnCellParsing
DataGridView.CellFormatting イベント
DataGridView.EditMode プロパティ
DataGridViewCell.ValueType プロパティ
DataGridViewCell.InheritedStyle プロパティ
DataGridViewCell.ParseFormattedValue
DataGridViewCellParsingEventHandler
ConvertEventArgs.Value プロパティ
InheritedCellStyle
ParsingApplied
DataGridViewCellStyle
DataGridViewCellStyle.NullValue
DataGridViewCellStyle.Format
DataGridViewCellStyle.FormatProvider



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

辞書ショートカット

すべての辞書の索引

「DataGridViewCellParsingEventArgs」の関連用語

DataGridViewCellParsingEventArgsのお隣キーワード
検索ランキング

   

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



DataGridViewCellParsingEventArgsのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS