Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

CurrentRow row status

$
0
0

Hi Guys
I have a datatable which indicates which image is currently being displayed. In datagridView cell click event it checks this table and change the status along with changing the image. I have to store this datatable into sql save the current row status. My problem is when I export this datatable back to my datagridview, the cell click event doesn't read anymore the status of the images. I have tried dt.AcceptChanges, itd didn't help. dt.LoadChanges, it reads correctley the unchanged rows but it won't read the modified rows at the first cell click. any idea how to fix this ? appreciated

Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
        If e.ColumnIndex = 1 Then
            If bsData.Current IsNot Nothing Then
                Dim CurrentRow As DataRow = CType(bsData.Current, DataRowView).Row
                If CurrentRow.Field(Of String)("CurrentImageName") = "Image1" Then
                    DataGridView1.Item("CompanyStatusImage", DataGridView1.CurrentRow.Index).Value = MyIcons.Proof
                    CurrentRow.SetField(Of String)("CurrentImageName", "Image2")
                Else
                    DataGridView1.Item("CompanyStatusImage", DataGridView1.CurrentRow.Index).Value = MyIcons.Blank
                    CurrentRow.SetField(Of String)("CurrentImageName", "Image1")
                End If
            End If
        End If


gdeal++


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>