DataGridViewCell.ValueType プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文
Dim instance As DataGridViewCell Dim value As Type value = instance.ValueType instance.ValueType = value
/** @property */ public Type get_ValueType () /** @property */ public void set_ValueType (Type value)
セル内の値のデータ型を表す Type。
セルの ValueType プロパティが設定されていない場合は、(存在すれば) そのセルを所有している列の DataGridViewColumn.ValueType プロパティが使用されます。
Value プロパティが、セルに格納されている実際のデータ オブジェクトであるのに対し、FormattedValue プロパティは、データの書式指定済みの表現です。ValueType プロパティと FormattedValueType プロパティは、これらの値のデータ型にそれぞれ対応しています。
セル値の変更時に ValueType プロパティを設定する方法を次のコード例に示します。次のコード例は、「方法 : 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); }
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- DataGridViewCell.ValueType プロパティのページへのリンク