DataGridViewCell.DefaultNewRowValue プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

既定値を表す Object。

基本クラス DataGridViewCell の DefaultNewRowValue プロパティは、常に null 参照 (Visual Basic では Nothing) を返します。ただし、このプロパティは、他の既定値を返すように、派生されたセル クラスでオーバーライドできます。
このプロパティが返す値は、新しいレコードの行にセルが存在する場合に表示されます。この値は、新しいレコードの行にフォーカスが移動したときに DataGridView.DefaultValuesNeeded イベントのハンドラでオーバーライドできます。

DataGridViewTextBoxCell から派生した CalendarCell クラスで DefaultNewRowValue プロパティを オーバーライドする方法を次のコード例に示します。次のコード例は、「方法 : Windows フォーム DataGridView Cells でコントロールをホストする」で示されている例の一部です。
Public Class CalendarCell Inherits DataGridViewTextBoxCell Public Sub New() ' Use the short date format. Me.Style.Format = "d" End Sub Public Overrides Sub InitializeEditingControl(ByVal rowIndex As Integer, _ ByVal initialFormattedValue As Object, _ ByVal dataGridViewCellStyle As DataGridViewCellStyle) ' Set the value of the editing control to the current cell value. MyBase.InitializeEditingControl(rowIndex, initialFormattedValue, _ dataGridViewCellStyle) Dim ctl As CalendarEditingControl = _ CType(DataGridView.EditingControl, CalendarEditingControl) ctl.Value = CType(Me.Value, DateTime) End Sub Public Overrides ReadOnly Property EditType() As Type Get ' Return the type of the editing contol that CalendarCell uses. Return GetType(CalendarEditingControl) End Get End Property Public Overrides ReadOnly Property ValueType() As Type Get ' Return the type of the value that CalendarCell contains. Return GetType(DateTime) End Get End Property Public Overrides ReadOnly Property DefaultNewRowValue() As Object Get ' Use the current date and time as the default value. Return DateTime.Now End Get End Property End Class
public class CalendarCell : DataGridViewTextBoxCell { public CalendarCell() : base() { // Use the short date format. this.Style.Format = "d"; } public override void InitializeEditingControl(int rowIndex, object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle) { // Set the value of the editing control to the current cell value. base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle); CalendarEditingControl ctl = DataGridView.EditingControl as CalendarEditingControl; ctl.Value = (DateTime)this.Value; } public override Type EditType { get { // Return the type of the editing contol that CalendarCell uses. return typeof(CalendarEditingControl); } } public override Type ValueType { get { // Return the type of the value that CalendarCell contains. return typeof(DateTime); } } public override object DefaultNewRowValue { get { // Use the current date and time as the default value. return DateTime.Now; } } }

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からDataGridViewCell.DefaultNewRowValue プロパティを検索する場合は、下記のリンクをクリックしてください。

- DataGridViewCell.DefaultNewRowValue プロパティのページへのリンク