Private Sub viewplans_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
con.Open()
da = New OleDbDataAdapter("select* from plandetails", con)
Dim cb As New OleDbCommandBuilder
cb = New OleDbCommandBuilder(da)
dt = New DataTable()
da.Fill(dt)
DataGridView1.DataSource = dt
DataGridView1.Columns(0).HeaderCell.Value = "ID"
DataGridView1.Columns(0).Width = 60
DataGridView1.Columns(1).HeaderCell.Value = "Name"
DataGridView1.Columns(1).Width = 100
DataGridView1.Columns(2).HeaderCell.Value = "Rate"
DataGridView1.Columns(2).Width = 80
Dim editcol As New DataGridViewImageColumn
editcol.Image = Image.FromFile("C:\Users\VP\Documents\Visual Studio 2008\Projects\GTPL SOFT\GTPL SOFT\Resources\edit.png")
editcol.DefaultCellStyle.SelectionBackColor = System.Drawing.Color.White
DataGridView1.Columns.Add(editcol)
editcol.Name = "editcol"
editcol.HeaderText = "Edit"
editcol.Width = 70
Dim delatecol As New DataGridViewImageColumn
' Dim img As Image
delatecol.Image = Image.FromFile("C:\Users\VP\Documents\Visual Studio 2008\Projects\GTPL SOFT\GTPL SOFT\Resources\delete.png")
delatecol.DefaultCellStyle.SelectionBackColor = System.Drawing.Color.White
DataGridView1.Columns.Add(delatecol)
delatecol.Name = "delatecol"
delatecol.HeaderText = "Delete"
delatecol.Width = 70
con.Close()
End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
'HOW CAN I EDIT SINGLE IMAGE ROW OF EDIT COLUMN USING CELLCONTENT CLICK
End Sub
Aryan Kumar
06-Jul-2023Sure, I can help you with that. Here are the steps on how to edit row data using single row image click in VB.NET data gridview:
Here is an example of the code you would need to edit row data using single row image click in VB.NET data gridview:
VB.Net
This code will create an image button and bind it to the GridView control. When the user clicks the image button, the code will get the selected row from the GridView control and bind the data from the selected row to the form controls. The form controls will then be enabled so that the user can edit the data. When the user clicks the Save button, the code will save the changes to the data.