Hi guys,
Im using a datagrid for user to enter input.
However,im restricting the grids to some value.My grid is actually not bounded to any database.
so,here is my requirement: whn the form is getting displayed,all grids are getting displayed.,which dont want.,only row2 shld get displayed to user after he'l finish entering values in row1..,please help..im using vb.net as front end and access as backend..
appreciate ur quick help..

Can you post your codes to help us understand better

Private Sub DataGridView1_CellValidated(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellValidated
        For Each r As DataGridViewRow In Me.DataGridView1.Rows
            If r.Cells(7).Value = "Regular" Then
                Sum = r.Cells(1).Value * r.Cells(2).Value
                r.Cells(3).Value = Sum
                r.Cells(5).Value = r.Cells(3).Value * r.Cells(4).Value
            End If
        Next r
    End Sub
Private Sub save_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles save_btn.Click

        Try
            Dim cnString As String
            Dim sex As String = ""
            cnString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source= E:\working proj\Varcos\RegistrationForm\RegistrationForm\bin\Data\" & frmAddData.project & ".mdb"
            Dim conn As OleDbConnection = New OleDbConnection(cnString)
            conn.Open()
            cmd = New OleDbCommand(sqlQRY, conn)

            For i = 0 To Dialog4.NUMBER_OF_ROWS_TO_ALLOW - 1
             
                sqlQRY = "Insert Into tblPlot(SurveyNo,PlotNo,Width,Depth,AreasqMtr,AreasqFt,RatePerSqFt,PlotCost,Facing,Status)"
                sqlQRY = sqlQRY & "Values"
                sqlQRY = sqlQRY & "('" & Me.surveya & "', '" & DataGridView1.Rows(i).Cells(0).Value & "', '" & DataGridView1.Rows(i).Cells(1).Value & "', '" & DataGridView1.Rows(i).Cells(2).Value & "', '" & DataGridView1.Rows(i).Cells(3).Value & "', '" & Round(Sum * 10.76391) & "', '" & DataGridView1.Rows(i).Cells(4).Value & "', '" & DataGridView1.Rows(i).Cells(5).Value & "','" & DataGridView1.Rows(i).Cells(6).Value & "','" & "Unbooked" & "')"
                With cmd
                    .CommandText = sqlQRY
                    .Connection = conn
                    .ExecuteNonQuery()
                End With
                DataGridView1.[ReadOnly] = False
                save_btn.Enabled = True
                frmPaymentSchedule.Plot = DataGridView1.Rows(i).Cells(0).Value.ToString
                DataGridView1.Rows(i).Cells(0).Value = Nothing
                DataGridView1.Rows(i).Cells(1).Value = Nothing
                DataGridView1.Rows(i).Cells(2).Value = Nothing
                DataGridView1.Rows(i).Cells(3).Value = Nothing
                DataGridView1.Rows(i).Cells(4).Value = Nothing
                DataGridView1.Rows(i).Cells(5).Value = Nothing
                DataGridView1.Rows(i).Cells(6).Value = Nothing
   Next i
     MsgBox("Data is Saved For Survey")
            Me.Close()
     Catch ex As Exception
            MsgBox("Incomplete Data,Please Fill All the Details!")
            Me.Visible = False
            Me.Show()
        End Try
        conn.Close()
    End Sub
Private Sub DataGridView1_CellValidated(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellValidated
        For Each r As DataGridViewRow In Me.DataGridView1.Rows
            If r.Cells(7).Value = "Regular" Then
                Sum = r.Cells(1).Value * r.Cells(2).Value
                r.Cells(3).Value = Sum
                r.Cells(5).Value = r.Cells(3).Value * r.Cells(4).Value
            End If
        Next r
    End Sub
Private Sub save_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles save_btn.Click

        Try
            Dim cnString As String
            Dim sex As String = ""
            cnString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source= E:\working proj\Varcos\RegistrationForm\RegistrationForm\bin\Data\" & frmAddData.project & ".mdb"
            Dim conn As OleDbConnection = New OleDbConnection(cnString)
            conn.Open()
            cmd = New OleDbCommand(sqlQRY, conn)

            For i = 0 To Dialog4.NUMBER_OF_ROWS_TO_ALLOW - 1
             
                sqlQRY = "Insert Into tblPlot(SurveyNo,PlotNo,Width,Depth,AreasqMtr,AreasqFt,RatePerSqFt,PlotCost,Facing,Status)"
                sqlQRY = sqlQRY & "Values"
                sqlQRY = sqlQRY & "('" & Me.surveya & "', '" & DataGridView1.Rows(i).Cells(0).Value & "', '" & DataGridView1.Rows(i).Cells(1).Value & "', '" & DataGridView1.Rows(i).Cells(2).Value & "', '" & DataGridView1.Rows(i).Cells(3).Value & "', '" & Round(Sum * 10.76391) & "', '" & DataGridView1.Rows(i).Cells(4).Value & "', '" & DataGridView1.Rows(i).Cells(5).Value & "','" & DataGridView1.Rows(i).Cells(6).Value & "','" & "Unbooked" & "')"
                With cmd
                    .CommandText = sqlQRY
                    .Connection = conn
                    .ExecuteNonQuery()
                End With
                DataGridView1.[ReadOnly] = False
                save_btn.Enabled = True
                frmPaymentSchedule.Plot = DataGridView1.Rows(i).Cells(0).Value.ToString
                DataGridView1.Rows(i).Cells(0).Value = Nothing
                DataGridView1.Rows(i).Cells(1).Value = Nothing
                DataGridView1.Rows(i).Cells(2).Value = Nothing
                DataGridView1.Rows(i).Cells(3).Value = Nothing
                DataGridView1.Rows(i).Cells(4).Value = Nothing
                DataGridView1.Rows(i).Cells(5).Value = Nothing
                DataGridView1.Rows(i).Cells(6).Value = Nothing
   Next i
     MsgBox("Data is Saved For Survey")
            Me.Close()
     Catch ex As Exception
            MsgBox("Incomplete Data,Please Fill All the Details!")
            Me.Visible = False
            Me.Show()
        End Try
        conn.Close()
    End Sub
Private Sub DataGridView1_UserAddedRow(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowEventArgs) Handles DataGridView1.UserAddedRow
        DataGridView1.AllowUserToAddRows = DataGridView1.RowCount <= Dialog4.NUMBER_OF_ROWS_TO_ALLOW
    End Sub

FYI bro..

Bro,
in the above image,i have restricted the no of rows to 4.All rows are getting displayed whn the form is getting loaded.BUt i want to display only one row at a time.,for ex: second row shld come only whn the user finish entering details in row one.

Why you are adding 4 rows at load time just u want single row then use

dataGridView1.RowCount = 1

Follow the steps

Form load add

dataGridView1.RowCount = 1

On dataGridView1 Editcontrolshowing property add code if u want only 4 rows then

Private Sub dataGridView1_EditingControlShowing(sender As Object, e As DataGridViewEditingControlShowingEventArgs)
	If dataGridView1.CurrentRow.Index >= 4 Then
		Me.dataGridView1.AllowUserToAddRows = False
	Else
		Me.dataGridView1.AllowUserToAddRows = True
	End If

End Sub

Hope it will help you...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.