バージョン 24.2 (最新)

MinRows プロパティ

バンドで許可される最小の行数を取得または設定します。この値は包含的です。デフォルトは 0 です。バンドから行を削除しようとしたときに残りの行数が MinRows より少なくなる場合は、行は削除されずに UltraGrid.Error イベントが発生します。
シンタックス
public int MinRows {get; set;}
解説

MaxRowsMinRows は、RowsCollection が MaxRows 制約および MinRows 制約に違反する場合にユーザーが行を追加または削除できないようにします。これらのプロパティは、データソースに保存できるデータの内容には関与しません。ユーザーが一定のレベルを超えて行を追加または削除できるかどうかを制御するだけです。

使用例
Private Sub SetupGrid()
   ' Make sure that the user can add and delete rows from the grid.
   '
   Me.ultraGrid1.DisplayLayout.Override.AllowAddNew = AllowAddNew.TemplateOnBottom
   Me.ultraGrid1.DisplayLayout.Override.AllowDelete = DefaultableBoolean.True
   
   ' Make sure that the row selectors are displayed so that it is easy to delete rows.
   '
   Me.ultraGrid1.DisplayLayout.Override.RowSelectors = DefaultableBoolean.True
   
   ' Set the "EmergencyContacts" band to require that each row collection have between 1 and 3 rows.
   '
   Me.ultraGrid1.DisplayLayout.Bands("EmergencyContacts").MinRows = 1
   Me.ultraGrid1.DisplayLayout.Bands("EmergencyContacts").MaxRows = 3
End Sub


Private Sub ultraGrid1_Error(sender As Object, e As Infragistics.Win.UltraWinGrid.ErrorEventArgs) Handles Me.ultraGrid1.Error
   ' If the source of the error is 'RowDelete' and the Exception property is Nothing then the reason
   ' that this event fired was due to an attempt to violate the MinRows constraint.  The Exception
   ' property will be Nothing in this situation because no exception was thrown to cause this error, 
   ' but the grid's internal logic detected the error.  If the Exception property was not Nothing then
   ' that would indicate that data source threw an exception when the row was being deleted.
   '
   If e.DataErrorInfo.Source = DataErrorSource.RowDelete And e.DataErrorInfo.Exception Is Nothing Then
      MessageBox.Show("Each employee must have at least one emergency contact.", "Cannot Delete All Rows", MessageBoxButtons.OK, MessageBoxIcon.Information)
   End If
End Sub
'宣言
 
Public Property MinRows As Integer
 
private void SetupGrid()
{
	// Make sure that the user can add and delete rows from the grid.
	//
	this.ultraGrid1.DisplayLayout.Override.AllowAddNew = AllowAddNew.TemplateOnBottom;
	this.ultraGrid1.DisplayLayout.Override.AllowDelete = DefaultableBoolean.True;

	// Make sure that the row selectors are displayed so that it is easy to delete rows.
	//
	this.ultraGrid1.DisplayLayout.Override.RowSelectors = DefaultableBoolean.True;

	// Set the "EmergencyContacts" band to require that each row collection have between 1 and 3 rows.
	//
	this.ultraGrid1.DisplayLayout.Bands["EmergencyContacts"].MinRows = 1;
	this.ultraGrid1.DisplayLayout.Bands["EmergencyContacts"].MaxRows = 3;	
}

private void ultraGrid1_Error(object sender, Infragistics.Win.UltraWinGrid.ErrorEventArgs e)
{	
	// If the source of the error is 'RowDelete' and the Exception property is null then the reason
	// that this event fired was due to an attempt to violate the MinRows constraint.  The Exception
	// property will be null in this situation because no exception was thrown to cause this error, 
	// but the grid's internal logic detected the error.  If the Exception property was not null then
	// that would indicate that data source threw an exception when the row was being deleted.
	//
	if( e.DataErrorInfo.Source == DataErrorSource.RowDelete && e.DataErrorInfo.Exception == null )
	{
		MessageBox.Show( 
			"Each employee must have at least one emergency contact.", 
			"Cannot Delete All Rows",
			MessageBoxButtons.OK, 
			MessageBoxIcon.Information );
	}
}
'宣言
 
Public Property MinRows As Integer
 
参照