Check box getting unchecked while sorting column in datagridview
-
Check box column getting unchecked when I am sorting column in datagridview. Can any one can help me? Regds. Suman
-
Check box column getting unchecked when I am sorting column in datagridview. Can any one can help me? Regds. Suman
Hello Suman, I have checked this and it works fine for me. Could you please provide us a small sample application showing the mentioned behavior. Regards, Allen
Allen Smith ComponentOne LLC www.componentone.com
-
Hello Suman, I have checked this and it works fine for me. Could you please provide us a small sample application showing the mentioned behavior. Regards, Allen
Allen Smith ComponentOne LLC www.componentone.com
Imports System Imports System.Data.SqlClient Public Class Form1 Dim str As String Dim con As SqlConnection Dim da As SqlDataAdapter Dim ds As New DataSet Dim dt As DataTable Dim dv As DataView Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load str = "Integrated Security=SSPI; User Id=sa;Initial Catalog=MAS08; Data Source = suman" con = New SqlConnection(str) con.Open() str = "select * from unitmaster" da = New SqlDataAdapter(str, con) da.Fill(ds, "unitmaster") dt = ds.Tables(0) dv = New DataView(dt) Dim colCheckbox As New DataGridViewCheckBoxColumn() ' Size the column width so it is wide enough to display the header colCheckbox.AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader colCheckbox.ThreeState = False colCheckbox.TrueValue = 1 colCheckbox.FalseValue = 0 colCheckbox.IndeterminateValue = System.DBNull.Value colCheckbox.DataPropertyName = "Checkbox" colCheckbox.HeaderText = "Checkbox" colCheckbox.Name = "Checkbox" 'colCheckbox.ReadOnly = True dgv.Columns.Add(colCheckbox) dgv.DataSource = dv End Sub End Class