Private Sub DgvBranch_CellEndEdit(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DgvBranch.CellEndEdit Try If Not (IsNumeric(DgvBranch.Rows(e.RowIndex).Cells(e.ColumnIndex).Value)) Then DgvBranch.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = String.Empty Exit Sub End If If (e.ColumnIndex = 1) Then Dim value As Int32 = AsInt(DgvBranch.Rows(e.RowIndex).Cells(e.ColumnIndex).Value) Dim fromValue As Int32 = AsInt(DgvBranch.Rows(e.RowIndex).Cells(0).Value) If (Convert.ToInt32(value) < Convert.ToInt32(fromValue)) Then MessageBox.Show("End day should be max of start day") If currentValue > 0 Then DgvBranch.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = currentValue Else DgvBranch.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = String.Empty End If Exit Sub End If Dim nextToVal As Int32 = AsInt(DgvBranch.Rows(e.RowIndex + 1).Cells(e.ColumnIndex).Value) If (nextToVal > 0 And value >= nextToVal) Then DgvBranch.CommitEdit(New DataGridViewDataErrorContexts()) If (MessageBox.Show("Need to remove sub seq data", "Confirm", MessageBoxButtons.YesNo) = DialogResult.Yes) Then 'Hear i am remove the rows and assign the value =0 ,But i need do delete the rows For index = e.RowIndex + 1 To DgvBranch.Rows.Count - 1 DgvBranch.Rows(index).Cells(0).Value = "0" DgvBranch.Rows(index).Cells(1).Value = "0" DgvBranch.Rows(index).Cells(2).Value = "0" Next ElseIf (currentValue > 0) Then DgvBranch.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = currentValue ElseIf (nextToVal > 0) Then DgvBranch.Rows(e.RowIndex + 1).Cells(0).Value = value + 1 End If ElseIf (nextToVal > 0) Then DgvBranch.Rows(e.RowIndex + 1).Cells(0).Value = value + 1 End If End If Catch ex As Exception MainForm.ErrorMsg.StatusBarMsg(ex.Message.ToString, Bx_UI_COM_ErrorMsg.ErrorComponent.MessageType.bx_Error) End Try End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)