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

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

DataGridViewCell.Value プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

このセル関連付けられている値を取得または設定します

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

例外例外
例外種類条件

ArgumentOutOfRangeException

RowIndex が有効な範囲 (0 ~コントロール行数 - 1) 内にありません。

InvalidOperationException

ColumnIndex が 0 未満です。これは、セルが行ヘッダーセルであることを示します

解説解説

別の値をセル割り当てると、DataGridView コントロールの CellValueChanged イベント発生します

Value プロパティが、セル格納されている実際のデータ オブジェクトであるのに対し、FormattedValue プロパティは、データ書式指定済み表現です。ValueType プロパティと FormattedValueType プロパティは、これらの値のデータ型それぞれ対応してます。

Value プロパティ設定すると、指定された値は、書式設定された表示用の値から、基になるセル値に自動変換されません。たとえば、セルに対して有効な DataGridViewCellStyle が無視されるため、Value を DataGridViewCellStyle.NullValue に設定すると、DataGridViewCellStyle.DataSourceNullValue のプロパティ値が生成されなくなります

使用例使用例

Value プロパティ使用してセル内容更新する方法次のコード例示します次のコード例は、「方法 : Windows フォームの DataGridView コントロールの行を操作する」で示されている例の一部です。

' Give cheescake excellent rating.
Private Sub Button8_Click(ByVal
 sender As Object, _
    ByVal e As System.EventArgs) Handles
 Button8.Click

    UpdateStars(dataGridView.Rows(4), "******************")
End Sub

Private ratingColumn As Integer
 = 3

Private Sub UpdateStars(ByVal
 row As DataGridViewRow, _
    ByVal stars As String)

    row.Cells(ratingColumn).Value = stars

    ' Resize the column width to account for the new value.
    row.DataGridView.AutoResizeColumn(ratingColumn, _
        DataGridViewAutoSizeColumnMode.DisplayedCells)

End Sub
// Give cheescake excellent rating.
private void Button8_Click(object sender,
    System.EventArgs e)
{
    UpdateStars(dataGridView.Rows[4], "******************");
}

int ratingColumn = 3;

private void UpdateStars(DataGridViewRow row,
 string stars)
{

    row.Cells[ratingColumn].Value = stars;

    // Resize the column width to account for the new value.
    row.DataGridView.AutoResizeColumn(ratingColumn, 
        DataGridViewAutoSizeColumnMode.DisplayedCells);
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGridViewCell クラス
DataGridViewCell メンバ
System.Windows.Forms 名前空間
DataGridView クラス
DataGridViewCell.Tag プロパティ
ValueType
DataGridViewCell.FormattedValue プロパティ
DataGridView.CellValueChanged イベント



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

辞書ショートカット

すべての辞書の索引

「DataGridViewCell.Value プロパティ」の関連用語

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

   

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



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

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

©2024 GRAS Group, Inc.RSS