Export (0) Print
Expand All

DataGridViewRow::IsNewRow Property

Gets a value indicating whether the row is the row for new records.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

[BrowsableAttribute(false)]
public:
property bool IsNewRow {
	bool get ();
}

Property Value

Type: System::Boolean
true if the row is the last row in the DataGridView, which is used for the entry of a new row of data; otherwise, false.

Because the row for new records is in the Rows collection, use the IsNewRow property to determine whether a row is the row for new records or is a populated row.

A row stops being the new row when data entry into the row begins.

The following code example uses the IsNewRow property to prevent attempts to set the label of the row for new records.

   // Set row labels. 
   void Button6_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {

      int rowNumber = 1;
      System::Collections::IEnumerator^ myEnum = safe_cast<System::Collections::IEnumerable^>(dataGridView->Rows)->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         DataGridViewRow^ row = safe_cast<DataGridViewRow^>(myEnum->Current);
         if ( row->IsNewRow )
                  continue;
         row->HeaderCell->Value = String::Format( L"Row {0}", rowNumber );

         rowNumber = rowNumber + 1;
      }

      dataGridView->AutoResizeRowHeadersWidth( DataGridViewRowHeadersWidthSizeMode::AutoSizeToAllHeaders );
   }

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft