DataGridViewRow.SetValues Method

Sets the values of the row's cells.

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

public bool SetValues(
	params Object[] values
)

Parameters

values
Type: System.Object[]

One or more objects that represent the cell values in the row.

-or-

An Array of Object values.

Return Value

Type: System.Boolean
true if all values have been set; otherwise, false.

ExceptionCondition
ArgumentNullException

values is null.

InvalidOperationException

This method is called when the associated DataGridView is operating in virtual mode.

-or-

This row is a shared row.

The values parameter represents a variable number of arguments used to populate cell values in the row. These values can be passed to this method as multiple, individual arguments or as members of a single Array. Because the values are expected to be instances of type Object, however, if you pass in an array of value-type values (such as Int32 values), this method will treat the array as a single object and assign it to a single cell. To avoid this behavior, you must cast a value-type array to an Object array or pass in multiple values as multiple arguments.

If there are more values in the values list than there are cells to be initialized, this method ignores the extra values and returns false. This method also returns false if any of the specified values cannot be set.

If there are fewer values than there are cells, the remaining unmatched cells retain their current values.

.NET Framework

Supported in: 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.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft