---
title: "How to insert,update,delete,next previous button in a single form vb.net winform."  
description: "How to insert,update,delete,next previous button in a single form vb.net winform."  
author: "Anonymous User"  
published: 2016-01-01  
updated: 2023-07-06  
canonical: https://www.mindstick.com/forum/33821/how-to-insert-update-delete-next-previous-button-in-a-single-form-vb-dot-net-winform  
category: "vb.net"  
tags: ["vb.net", "winforms"]  
reading_time: 14 minutes  

---

# How to insert,update,delete,next previous button in a single form vb.net winform.

I want to use [insert](https://www.mindstick.com/blog/173/executing-insert-delete-or-update-query-in-sqlserver-using-ado-dot-net),[update](https://www.mindstick.com/forum/156353/what-is-hummingbird-update),[delete](https://www.mindstick.com/forum/33620/how-to-delete-record-from-list-in-mvc-using-ajax),next [previous](https://yourviews.mindstick.com/view/81421/unlock-2-0-is-just-like-previous-corona-lockdowns) [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) in a single [form](https://www.mindstick.com/forum/6/multi-form-mfc-application) [vb.net winform](https://www.mindstick.com/forum/33830/how-to-calculate-data-grid-value-and-textbox-value-on-change-in-vb-dot-net-winform). how will do this please helpme.

## Replies

### Reply by Aryan Kumar

Sure, I can help you with that. Here are the steps on how to insert, update, delete, next, previous button in a single [vb.net](https://www.mindstick.com/forum/426/sqlsever-2000-in-network-with-vb-dot-net-2008) winform:

1. Create a new Windows Forms project in VB.NET.
2. Add a button control for each of the operations you want to perform (insert, update, delete, next, previous).
3. Add a datagridview control to the form.
4. Bind the datagridview control to some data.
5. Add event handlers for the buttons.
6. In the event handlers, perform the corresponding operation on the datagridview control.

Here is an example of the code you would need to insert, update, delete, next, previous button in a single vb.net winform:

VB.Net

```plaintext
Private Sub ButtonInsert_Click(sender As Object, e As EventArgs) Handles ButtonInsert.Click
    ' Insert a new row in the datagridview control.
    DataGridView1.Rows.Add()
End Sub

Private Sub ButtonUpdate_Click(sender As Object, e As EventArgs) Handles ButtonUpdate.Click
    ' Update the selected row in the datagridview control.
    Dim selectedRow As DataGridViewRow = DataGridView1.SelectedRows(0)

    ' Get the values from the textbox controls.
    Dim txtName As TextBox = Me.Controls.Find("txtName", True)
    Dim txtEmail As TextBox = Me.Controls.Find("txtEmail", True)

    ' Set the values in the selected row.
    selectedRow.Cells(0).Value = txtName.Text
    selectedRow.Cells(1).Value = txtEmail.Text
End Sub

Private Sub ButtonDelete_Click(sender As Object, e As EventArgs) Handles ButtonDelete.Click
    ' Delete the selected row in the datagridview control.
    Dim selectedRow As DataGridViewRow = DataGridView1.SelectedRows(0)

    ' Delete the row.
    DataGridView1.Rows.Remove(selectedRow)
End Sub

Private Sub ButtonNext_Click(sender As Object, e As EventArgs) Handles ButtonNext.Click
    ' Select the next row in the datagridview control.
    Dim selectedRow As DataGridViewRow = DataGridView1.SelectedRows(0)

    ' If the current row is the last row, select the first row.
    If selectedRow.Index = DataGridView1.Rows.Count - 1 Then
        DataGridView1.SelectedRows(0) = DataGridView1.Rows(0)
    Else
        DataGridView1.SelectedRows(0) = DataGridView1.Rows(selectedRow.Index + 1)
    End If
End Sub

Private Sub ButtonPrevious_Click(sender As Object, e As EventArgs) Handles ButtonPrevious.Click
    ' Select the previous row in the datagridview control.
    Dim selectedRow As DataGridViewRow = DataGridView1.SelectedRows(0)

    ' If the current row is the first row, select the last row.
    If selectedRow.Index = 0 Then
        DataGridView1.SelectedRows(0) = DataGridView1.Rows(DataGridView1.Rows.Count - 1)
    Else
        DataGridView1.SelectedRows(0) = DataGridView1.Rows(selectedRow.Index - 1)
    End If
End Sub
```

This code will create a button control for each of the operations you want to perform. The buttons will be bound to the datagridview control. The event handlers for the buttons will perform the corresponding operation on the datagridview control.

### Reply by Anonymous User

i am using Multiple action in a single form such as add,edit,delete,save,first,next,previous,last,exit,cancel,and textbox value change ,combobox value change .following code below ->

```
Public Class frmledger
    Dim obj As New ledgerBAL
    Dim objBAL As New ledgerDAL
    'enter key tab handler Event
    Private Sub frmledger_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If e.KeyCode = Keys.Enter Then
            SendKeys.Send("{TAB}")
      ElseIf e.Control Then
            If e.KeyCode = Keys.A Then
                btnadd.PerformClick()
            ElseIf e.KeyCode = Keys.C Then
                btncancel.PerformClick()
            ElseIf e.KeyCode = Keys.E Then
                btnedit.PerformClick()
            ElseIf e.KeyCode = Keys.S Then
                btnupdate.PerformClick()
            ElseIf e.KeyCode = Keys.D Then
                btndelete.PerformClick()
            ElseIf e.KeyCode = Keys.F Then
                btnfrist.PerformClick()
            ElseIf e.KeyCode = Keys.N Then
                btnnext.PerformClick()
            ElseIf e.KeyCode = Keys.P Then
                btnprevious.PerformClick()
            ElseIf e.KeyCode = Keys.L Then
                btnlast.PerformClick()
            ElseIf e.KeyCode = Keys.X Then
                btnclose.PerformClick()
            End If
        ElseIf e.KeyCode = Keys.Escape Then

            Dim result = MessageBox.Show(" Are you sure close This. ", "Are you sure?", MessageBoxButtons.OKCancel)
            If result = DialogResult.OK Then
                frmledger_list.Listview_Data()
                Me.Close()
            End If
        End If
    End Sub
    Private Sub frmledger_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        fill_Column()
        fill_accounttype(cboactype)
        fill_Cform(cboform)
        fill_TDS(cbotds)
        objBAL.Get_Data_Table()
        Last()
        txtledid.Focus()
    End Sub
    Public Sub fill_Column()
        Dim cbotype, cbobroker As New DataGridViewComboBoxColumn

        With cbotype
            .Name = "billtype"
            .HeaderText = "Bill Type"
            .Width = 200
        End With
        fillGrid_BillType(cbotype)
        With cbobroker
            .Name = "cbobroker"
            .HeaderText = "Broker"
            .Width = 250
        End With
        With dvggrid
            .Columns.Add(cbotype)
            .Columns.Add("billno", "Bill No")
            .Columns.Add("billdate", "Bill Date")
            .Columns.Add("billamnt", "Bill Amount")
            .Columns("billamnt").Width = 150
            .Columns.Add("billrecamnt", "Paid Amount")
            .Columns.Add("billbal", "Bill Balance")
            .Columns.Add(cbobroker)
        End With
    End Sub
    Private Sub dvggrid_EditingControlShowing(sender As System.Object, e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles dvggrid.EditingControlShowing
        AddHandler e.Control.KeyPress, AddressOf dvggrid_KeyPress
        Dim cb As ComboBox
        If TypeOf e.Control Is ComboBox Then
            cb = e.Control
            'set the dropdown style of a combobox
            cb.DropDownStyle = ComboBoxStyle.DropDown
            'set the propety of a combobox to autocomplete mode.
            cb.AutoCompleteMode = AutoCompleteMode.SuggestAppend
            cb.AutoCompleteSource = AutoCompleteSource.ListItems

        End If
    End Sub
    Private Sub dvggrid_CellEnter(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dvggrid.CellEnter
        ''# Code to Dropdown DataGridViewComboBox in single click
        ''Header Cell clicked -> ignore it.
        If (e.RowIndex = -1) Then
            Return
        End If
        dvggrid.BeginEdit(True)
        If TypeOf dvggrid.EditingControl Is DataGridViewComboBoxEditingControl Then
            Dim control As DataGridViewComboBoxEditingControl = dvggrid.EditingControl
            If Not IsNothing(control) Then
                control.DroppedDown = True
            End If
        End If
        '#End of Code to Dropdown DataGridViewComboBox
    End Sub
    Private Sub dvggrid_KeyPress(sender As System.Object, e As System.Windows.Forms.KeyPressEventArgs) Handles dvggrid.KeyPress
        If dvggrid.CurrentCell.ColumnIndex = 1 Or _
            dvggrid.CurrentCell.ColumnIndex = 2 Or _
            dvggrid.CurrentCell.ColumnIndex = 3 Then
            AllowOnlyNumeric(e, ".")
        End If
    End Sub
    Public Sub fill_filterdata()
        obj.led_id = txtledid.Text
        obj.Get_Data(obj)
        txtledid.Text = obj.led_id
        txtledname.Text = obj.led_Name
        txtadd1.Text = obj.Add1
        txtadd2.Text = obj.Add2
        txtadd3.Text = obj.Add3
        txtbadd1.Text = obj.Badd1
        txtbadd2.Text = obj.Badd2
        txtbadd3.Text = obj.Badd3
        txtmobile1.Text = obj.Mobile1
        txtmobile2.Text = obj.Mobile2
        txtphone1.Text = obj.phone1
        txtphone2.Text = obj.phone2
        txtfax.Text = obj.fax
        txtwebsite.Text = obj.Website
        txtemail.Text = obj.Email
        txtvattin.Text = obj.vat
        txtcsttinno.Text = obj.Csttax
        txtpanno.Text = obj.Pan_no
        txttanno.Text = obj.tanno
        txtservicetax.Text = obj.ser_tax
        cboform.SelectedValue = obj.form
        cboactype.SelectedValue = obj.ac_type
        txtbroker.Text = obj.br_name
        txtbroker_code.Text = obj.br_cd
        txtac_groupname.Text = obj.ac_name
        cbotds.SelectedValue = obj.tds
        txtconpersion.Text = obj.con_persion
        txtdesignation.Text = obj.Designation
        txtac_groupcode.Text = obj.ac_cd
        If obj.Page = 1 Then
            btnprevious.Enabled = False
            btnfrist.Enabled = False
            btnnext.Enabled = False
            btnlast.Enabled = False
        ElseIf obj.Page = Convert.ToInt32(lblrecordno.Text) Then
            btnprevious.Enabled = True
            btnfrist.Enabled = True
            btnnext.Enabled = False
            btnlast.Enabled = False
        Else
            btnprevious.Enabled = True
            btnfrist.Enabled = True
            btnnext.Enabled = True
            btnlast.Enabled = True
        End If

    End Sub
    Public Sub Nexts()
        obj.Page = obj.Page + 1
        obj.led_id = ""
        obj.Get_Data(obj)
        txtledid.Text = obj.led_id
        txtledname.Text = obj.led_Name
        txtadd1.Text = obj.Add1
        txtadd2.Text = obj.Add2
        txtadd3.Text = obj.Add3
        txtbadd1.Text = obj.Badd1
        txtbadd2.Text = obj.Badd2
        txtbadd3.Text = obj.Badd3
        txtmobile1.Text = obj.Mobile1
        txtmobile2.Text = obj.Mobile2
        txtphone1.Text = obj.phone1
        txtphone2.Text = obj.phone2
        txtfax.Text = obj.fax
        txtwebsite.Text = obj.Website
        txtemail.Text = obj.Email
        txtvattin.Text = obj.vat
        txtcsttinno.Text = obj.Csttax
        txtpanno.Text = obj.Pan_no
        txttanno.Text = obj.tanno
        txtservicetax.Text = obj.ser_tax
        cboform.SelectedValue = obj.form
        cboactype.SelectedValue = obj.ac_type
        txtbroker.Text = obj.br_name
        txtbroker_code.Text = obj.br_cd
        txtac_groupname.Text = obj.ac_name
        cbotds.SelectedValue = obj.tds
        txtconpersion.Text = obj.con_persion
        txtdesignation.Text = obj.Designation
        txtac_groupcode.Text = obj.ac_cd
        If obj.Page = 1 Then
            btnprevious.Enabled = False
            btnfrist.Enabled = False
            btnnext.Enabled = True
            btnlast.Enabled = True
            btnupdate.Enabled = False
            btncancel.Enabled = False
        ElseIf obj.Page = lblrecordno.Text Then
            btnprevious.Enabled = True
            btnfrist.Enabled = True
            btnnext.Enabled = False
            btnlast.Enabled = False
            btnupdate.Enabled = False
            btncancel.Enabled = False
        ElseIf obj.page > 1 Then
            btnprevious.Enabled = True
            btnfrist.Enabled = True
            btnnext.Enabled = True
            btnlast.Enabled = True
            btnupdate.Enabled = False
            btncancel.Enabled = False
        End If


    End Sub
    Public Sub Back()
        obj.Page = obj.Page - 1
        obj.led_id = ""
        obj.Get_Data(obj)
        txtledid.Text = obj.led_id
        txtledname.Text = obj.led_Name
        txtadd1.Text = obj.Add1
        txtadd2.Text = obj.Add2
        txtadd3.Text = obj.Add3
        txtbadd1.Text = obj.Badd1
        txtbadd2.Text = obj.Badd2
        txtbadd3.Text = obj.Badd3
        txtmobile1.Text = obj.Mobile1
        txtmobile2.Text = obj.Mobile2
        txtphone1.Text = obj.phone1
        txtphone2.Text = obj.phone2
        txtfax.Text = obj.fax
        txtwebsite.Text = obj.Website
        txtemail.Text = obj.Email
        txtvattin.Text = obj.vat
        txtcsttinno.Text = obj.Csttax
        txtpanno.Text = obj.Pan_no
        txttanno.Text = obj.tanno
        txtservicetax.Text = obj.ser_tax
        cboform.SelectedValue = obj.form
        cboactype.SelectedValue = obj.ac_type
        txtbroker.Text = obj.br_name
        txtbroker_code.Text = obj.br_cd
        txtac_groupname.Text = obj.ac_name
        cbotds.SelectedValue = obj.tds
        txtconpersion.Text = obj.con_persion
        txtdesignation.Text = obj.Designation
        txtac_groupcode.Text = obj.ac_cd
        If obj.Page = 1 Then
            btnprevious.Enabled = False
            btnfrist.Enabled = False
            btnnext.Enabled = True
            btnlast.Enabled = True
            btnupdate.Enabled = False
            btncancel.Enabled = False

        ElseIf obj.Page > 1 Then
            btnprevious.Enabled = True
            btnfrist.Enabled = True
            btnnext.Enabled = True
            btnlast.Enabled = True
            btnupdate.Enabled = False
            btncancel.Enabled = False
        End If

    End Sub
    Public Sub first()
        obj.Page = 1
        obj.led_id = ""
        obj.Get_Data(obj)
        txtledid.Text = obj.led_id
        txtledname.Text = obj.led_Name
        txtadd1.Text = obj.Add1
        txtadd2.Text = obj.Add2
        txtadd3.Text = obj.Add3
        txtbadd1.Text = obj.Badd1
        txtbadd2.Text = obj.Badd2
        txtbadd3.Text = obj.Badd3
        txtmobile1.Text = obj.Mobile1
        txtmobile2.Text = obj.Mobile2
        txtphone1.Text = obj.phone1
        txtphone2.Text = obj.phone2
        txtfax.Text = obj.fax
        txtwebsite.Text = obj.Website
        txtemail.Text = obj.Email
        txtvattin.Text = obj.vat
        txtcsttinno.Text = obj.Csttax
        txtpanno.Text = obj.Pan_no
        txttanno.Text = obj.tanno
        txtservicetax.Text = obj.ser_tax
        cboform.SelectedValue = obj.form
        cboactype.SelectedValue = obj.ac_type
        txtbroker.Text = obj.br_name
        txtbroker_code.Text = obj.br_cd
        txtac_groupname.Text = obj.ac_name
        cbotds.SelectedValue = obj.tds
        txtconpersion.Text = obj.con_persion
        txtdesignation.Text = obj.Designation
        txtac_groupcode.Text = obj.ac_cd
        If obj.Page = 1 Then
            btnprevious.Enabled = False
            btnfrist.Enabled = False
            btnnext.Enabled = True
            btnlast.Enabled = True
            btnupdate.Enabled = False
            btncancel.Enabled = False
        End If
    End Sub
    Public Sub Last()
        obj.Page = 0
        obj.led_id = ""
        obj.Get_Data(obj)
        txtledid.Text = obj.led_id
        txtledname.Text = obj.led_Name
        txtadd1.Text = obj.Add1
        txtadd2.Text = obj.Add2
        txtadd3.Text = obj.Add3
        txtbadd1.Text = obj.Badd1
        txtbadd2.Text = obj.Badd2
        txtbadd3.Text = obj.Badd3
        txtmobile1.Text = obj.Mobile1
        txtmobile2.Text = obj.Mobile2
        txtphone1.Text = obj.phone1
        txtphone2.Text = obj.phone2
        txtfax.Text = obj.fax
        txtwebsite.Text = obj.Website
        txtemail.Text = obj.Email
        txtvattin.Text = obj.vat
        txtcsttinno.Text = obj.Csttax
        txtpanno.Text = obj.Pan_no
        txttanno.Text = obj.tanno
        txtservicetax.Text = obj.ser_tax
        cboform.SelectedValue = obj.form
        cboactype.SelectedValue = obj.ac_type
        txtbroker.Text = obj.br_name
        txtbroker_code.Text = obj.br_cd
        txtac_groupname.Text = obj.ac_name
        cbotds.SelectedValue = obj.tds
        txtconpersion.Text = obj.con_persion
        txtdesignation.Text = obj.Designation
        txtac_groupcode.Text = obj.ac_cd
        lblrecordno.Text = obj.Page
        Desable()
        If obj.Page > 1 Then
            btnprevious.Enabled = True
            btnfrist.Enabled = True
            btnlast.Enabled = False
            btnnext.Enabled = False
            btnupdate.Enabled = False
            btncancel.Enabled = False
        ElseIf obj.Page = 1 Then
            btnprevious.Enabled = False
            btnfrist.Enabled = False
            btnnext.Enabled = False
            btnlast.Enabled = False

            btnupdate.Enabled = False
            btncancel.Enabled = False
        End If
        If obj.msg = "Yes" Then
            btndelete.Enabled = True
            btnedit.Enabled = True

        Else
            btndelete.Enabled = False
            btnedit.Enabled = False
            btnprevious.Enabled = False
            btnfrist.Enabled = False
            btnlast.Enabled = False
            btnnext.Enabled = False
            btnupdate.Enabled = False
            btncancel.Enabled = False
            btnadd.Enabled = True
        End If

    End Sub
    Public Sub insert_data()
        If txtledname.Text = "" Then
            MsgBox("Party Name Can Not be blank.")
            txtledname.Focus()
            Exit Sub
        Else
            If cbotds.SelectedValue = Nothing Then
                obj.tds = 0
            Else
                obj.tds = IIf(IsDBNull(cbotds.SelectedValue), 0, cbotds.SelectedValue)
            End If
            If cboform.SelectedValue = Nothing Then
                obj.form = 0
            Else
                obj.form = IIf(IsDBNull(cboform.SelectedValue), 0, cboform.SelectedValue)
            End If
            If cboactype.SelectedValue = Nothing Then
                obj.ac_type = 0
            Else
                obj.ac_type = IIf(IsDBNull(cboactype.SelectedValue), 0, cboactype.SelectedValue)
            End If
            obj.led_id = txtledid.Text
            obj.led_Name = IIf(IsDBNull(txtledname.Text), "", txtledname.Text)
            obj.Add1 = IIf(IsDBNull(txtadd1.Text), "", txtadd1.Text)
            obj.Add2 = IIf(IsDBNull(txtadd2.Text), "", txtadd2.Text)
            obj.Add3 = IIf(IsDBNull(txtadd3.Text), "", txtadd3.Text)
            obj.Badd1 = IIf(IsDBNull(txtbadd1.Text), "", txtbadd1.Text)
            obj.Badd2 = IIf(IsDBNull(txtbadd2.Text), "", txtbadd2.Text)
            obj.Badd3 = IIf(IsDBNull(txtbadd3.Text), "", txtbadd3.Text)
            obj.phone1 = IIf(IsDBNull(txtmobile1.Text), "", txtmobile1.Text)
            obj.phone2 = IIf(IsDBNull(txtmobile2.Text), "", txtmobile2.Text)
            obj.Mobile1 = IIf(IsDBNull(txtmobile1.Text), "", txtmobile1.Text)
            obj.Mobile2 = IIf(IsDBNull(txtmobile2.Text), "", txtmobile2.Text)
            obj.fax = IIf(IsDBNull(txtfax.Text), "", txtfax.Text)
            obj.Website = IIf(IsDBNull(txtwebsite.Text), "", txtwebsite.Text)
            obj.Email = IIf(IsDBNull(txtemail.Text), "", txtemail.Text)
            obj.vat = IIf(IsDBNull(txtvattin.Text), "", txtvattin.Text)
            obj.Csttax = IIf(IsDBNull(txtcsttinno.Text), "", txtcsttinno.Text)
            obj.Pan_no = IIf(IsDBNull(txtpanno.Text), "", txtpanno.Text)
            obj.tanno = IIf(IsDBNull(txttanno.Text), "", txttanno.Text)
            obj.ser_tax = IIf(IsDBNull(txtservicetax.Text), "", txtservicetax.Text)
            obj.br_cd = IIf(IsDBNull(txtbroker_code.Text), "", txtbroker_code.Text)
            obj.ac_cd = IIf(IsDBNull(txtac_groupcode.Text), "", txtac_groupcode.Text)
            obj.con_persion = IIf(IsDBNull(txtconpersion.Text), "", txtconpersion.Text)
            obj.Designation = IIf(IsDBNull(txtdesignation.Text), "", txtdesignation.Text)
            objBAL.insert_LEDGER(obj)
            cleare()
            Last()
            Desable()
            btnadd.Enabled = True
            btncancel.Enabled = False
            btnedit.Enabled = True
            btnclose.Enabled = True
            btndelete.Enabled = True
            btnupdate.Enabled = False
        End If
    End Sub
    Public Sub cleare()
        txtledid.Text = ""
        txtledname.Text = ""
        txtadd1.Text = ""
        txtadd2.Text = ""
        txtadd3.Text = ""
        txtbadd1.Text = ""
        txtbadd2.Text = ""
        txtbadd3.Text = ""
        txtmobile1.Text = ""
        txtmobile2.Text = ""
        txtphone1.Text = ""
        txtphone2.Text = ""
        txtconpersion.Text = ""
        txtdesignation.Text = ""
        txtfax.Text = ""
        txtwebsite.Text = ""
        txtemail.Text = ""
        txtvattin.Text = ""
        txtcsttinno.Text = ""
        txtpanno.Text = ""
        txtservicetax.Text = ""
        cboactype.SelectedValue = "0"
        txtbroker_code.Text = ""
        txtac_groupname.Text = ""
        txtac_groupcode.Text = ""
        txtbroker.Text = ""
        cbotds.SelectedValue = "0"
        cboform.SelectedValue = "0"
        txttanno.Text = ""
        txtledname.Focus()
    End Sub
    Public Sub Desable()
        txtbroker.Enabled = False
        txtledname.Enabled = False
        txtadd1.Enabled = False
        txtadd2.Enabled = False
        txtadd3.Enabled = False
        txtbadd1.Enabled = False
        txtbadd2.Enabled = False
        txtbadd3.Enabled = False
        txtmobile1.Enabled = False
        txtmobile2.Enabled = False
        txtphone1.Enabled = False
        txtphone2.Enabled = False
        txtfax.Enabled = False
        txtwebsite.Enabled = False
        txtemail.Enabled = False
        txtvattin.Enabled = False
        txtcsttinno.Enabled = False
        txtpanno.Enabled = False
        txtservicetax.Enabled = False
        cboactype.Enabled = False
        txtac_groupname.Enabled = False
        cbotds.Enabled = False
        cboform.Enabled = False
        txtconpersion.Enabled = False
        txtdesignation.Enabled = False
        txttanno.Enabled = False
        txtledid.Focus()
    End Sub
    Public Sub Enable()
        txttanno.Enabled = True
        txtconpersion.Enabled = True
        txtdesignation.Enabled = True
        txtledname.Enabled = True
        txtadd1.Enabled = True
        txtadd2.Enabled = True
        txtadd3.Enabled = True
        txtbadd1.Enabled = True
        txtbadd2.Enabled = True
        txtbadd3.Enabled = True
        txtmobile1.Enabled = True
        txtmobile2.Enabled = True
        txtphone1.Enabled = True
        txtphone2.Enabled = True
        txtfax.Enabled = True
        txtwebsite.Enabled = True
        txtemail.Enabled = True
        txtvattin.Enabled = True
        txtcsttinno.Enabled = True
        txtpanno.Enabled = True
        txtservicetax.Enabled = True
        cboactype.Enabled = True
        txtac_groupname.Enabled = True
        cbotds.Enabled = True
        cboform.Enabled = True
        txtbroker.Enabled = True
    End Sub

    Private Sub cboform_GotFocus(sender As Object, e As System.EventArgs) Handles cboform.GotFocus
        cboform.DroppedDown = True
    End Sub

    Private Sub cbotds_GotFocus(sender As Object, e As System.EventArgs) Handles cbotds.GotFocus
        cbotds.DroppedDown = True
    End Sub

    Private Sub cboactype_GotFocus(sender As Object, e As System.EventArgs) Handles cboactype.GotFocus
        cboactype.DroppedDown = True
    End Sub
    Private Sub txtbroker_KeyDown(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Handles txtbroker.KeyDown
        If (e.KeyCode = Keys.F1) Then
            formname = Me.Name
            frmbroker_list.ShowDialog()
        End If
    End Sub

    Private Sub cboactype_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cboactype.SelectedIndexChanged
        If (cboactype.Text = "CUSTOMER" Or cboactype.Text = "SUPPLIER") Then
            txtbroker.Enabled = True
        Else
            txtbroker.Enabled = False
        End If
    End Sub
    Private Sub txtledname_KeyDown(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Handles txtledname.KeyDown
        If (e.KeyCode = Keys.F1) Then
            formname = Me.Name
            sfilter = ""
            frmledger_list.ShowDialog()
        End If
    End Sub
    Private Sub btnadd_Click(sender As System.Object, e As System.EventArgs) Handles btnadd.Click
        Enable()
        cleare()
        txtledid.Text = Get_ID("ledger_master", "lc_cd", "LE/", False)
        btnadd.Enabled = False
        btncancel.Enabled = True
        btnedit.Enabled = False
        btnclose.Enabled = True
        btndelete.Enabled = False
        btnfrist.Enabled = False
        btnlast.Enabled = False
        btnnext.Enabled = False
        btnprevious.Enabled = False
        btnupdate.Enabled = True

    End Sub
    Private Sub btnedit_Click(sender As System.Object, e As System.EventArgs) Handles btnedit.Click
        Enable()
        btnadd.Enabled = False
        btncancel.Enabled = True
        btnedit.Enabled = False
        btnclose.Enabled = True
        btndelete.Enabled = True
        btnupdate.Enabled = True
        btnprevious.Enabled = False
        btnfrist.Enabled = False
        btnlast.Enabled = False
        btnnext.Enabled = False
    End Sub
    Private Sub btnupdate_Click(sender As System.Object, e As System.EventArgs) Handles btnupdate.Click
        insert_data()
    End Sub
    Private Sub btncancel_Click(sender As System.Object, e As System.EventArgs) Handles btncancel.Click
        btnadd.Enabled = True
        btncancel.Enabled = False
        btnedit.Enabled = True
        btnclose.Enabled = True
        btndelete.Enabled = True
        btnupdate.Enabled = False
        cleare()
        Desable()
        Last()
    End Sub
    Private Sub btndelete_Click(sender As System.Object, e As System.EventArgs) Handles btndelete.Click
        Dim result = MessageBox.Show(" Are you sure you want to Delete", "Are you sure?", MessageBoxButtons.OKCancel)
        If result = DialogResult.OK Then
            delrecsql("ledger_master", "lc_cd", txtledid.Text, False)
            cleare()
            Desable()
            Last()
        End If
    End Sub
    Private Sub btnfrist_Click(sender As System.Object, e As System.EventArgs) Handles btnfrist.Click
        Desable()
        first()
    End Sub
    Private Sub btnnext_Click(sender As System.Object, e As System.EventArgs) Handles btnnext.Click
        Desable()
        Nexts()
    End Sub
    Private Sub btnprevious_Click(sender As System.Object, e As System.EventArgs) Handles btnprevious.Click
        Desable()
        Back()
    End Sub

    Private Sub btnlast_Click(sender As System.Object, e As System.EventArgs) Handles btnlast.Click
        Desable()
        Last()
    End Sub
    Private Sub btnclose_Click(sender As System.Object, e As System.EventArgs) Handles btnclose.Click
        frmledger_list.Listview_Data()
        Me.Close()
    End Sub
    Private Sub txtledid_KeyDown(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Handles txtledid.KeyDown
        If (e.KeyCode = Keys.F1) Then
            formname = Me.Name
            sfilter = ""
            frmledger_list.ShowDialog()
        End If
    End Sub
    Private Sub TextBox_Leave(ByVal sender As Object, ByVal e As System.EventArgs) _
     Handles txtledname.Leave, txtac_groupname.Leave, txtbroker.Leave
        Dim tb As TextBox = DirectCast(sender, TextBox)
        With tb
            Select Case tb.Name
                Case "txtledname"
                    If CheckName("ledger_master", "lc_cd", txtledid.Text) = 1 Then
                    ElseIf CheckName("ledger_master", "replace(lc_name,' ','')", Replace(txtledname.Text, " ", "")) = 1 Then
                        MsgBox("This Name Already Exists !!")
                        Exit Sub
                    End If
                    If .Text = "" Then
                        MsgBox("This field is Required !!")
                    End If
                Case "txtbroker"
                    If .Text = "" Then
                        MsgBox("This field Select From Master Press F1  !!")
                    End If
                Case "txtac_groupname"
                    If .Text = "" Then
                        MsgBox("This field Select From Master Press F1  !!")
                    End If
            End Select
        End With
    End Sub

    Private Sub ComboBox_Leave(ByVal sender As Object, ByVal e As System.EventArgs) _
    Handles cboactype.Leave
        Dim tb As ComboBox = DirectCast(sender, ComboBox)
        With tb
            Select Case tb.Name
                Case "cboactype"
                    If .Text = "" Then
                        MsgBox("Please Select a Account Type !!")
                    End If
            End Select
        End With
    End Sub
    Private Sub txtac_groupname_KeyDown(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Handles txtac_groupname.KeyDown
        If (e.KeyCode = Keys.F1) Then
            formname = Me.Name
            accountgroup_list.ShowDialog()
        End If
    End Sub
End Class
```

![How to insert,update,delete,next previous button in a single form vb.net winform.](https://www.mindstick.com/mindstickforums/a66f546b-b01d-4e53-b45f-9378fd0c2673/images/a660d3aa-5099-4984-b184-b97167af9a25.png)\


---

Original Source: https://www.mindstick.com/forum/33821/how-to-insert-update-delete-next-previous-button-in-a-single-form-vb-dot-net-winform

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
