forum

Home / DeveloperSection / Forums / How can i edit row data using single row image click in vb.net Data Gridview

How can i edit row data using single row image click in vb.net Data Gridview

Vishu P118916-Sep-2018

 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



Updated on 06-Jul-2023

Can you answer this question?


Answer

1 Answers

Liked By