We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

error on grdMain_CellCheckBoxClick() event to capture checked and unchecked value

Thread ID:

Created:

Updated:

Platform:

Replies:

150688 Jan 16,2020 08:24 AM UTC Jan 17,2020 08:40 AM UTC WinForms 1
loading
Tags: SfDataGrid
sulthan
Asked On January 16, 2020 08:28 AM UTC

 '---Transaction bill Load Query---
    Private Sub transHistoryLoad()
        Dim constring As String = AlgoMdConnectionString
        Try
            Using con As New SqlConnection(constring)
                Using cmd As New SqlCommand("SELECT 
      [TTD_Col_Caption]
      ,[TTD_Col_UniqID]
      ,[TTD_Col_Visible]
      ,[TTD_Col_Display_order]
      ,[TTD_Col_DisplayType]
      ,[TTD_Col_DataType]      
      ,[TTD_Col_Editable]      
      ,[TTD_Col_Tab]
   ,[TTD_Col_Skip]
      ,[TTD_Col_Defa]
      ,[TTD_Col_NoDuplicates]
      ,[TTD_Col_Tab]
      ,'False' AS [Select All]
  FROM [dbo].[Tbl_Trans_Details]
", con)
                    cmd.CommandType = CommandType.Text
                    Using sda As New SqlDataAdapter(cmd)
                        Using ds As New DataSet()
                            sda.Fill(ds)
                            If ds.Tables(0).Rows.Count > 0 Then

                                grdMain.Columns.Add(New GridCheckBoxColumn() With {.MappingName = "Select All", .HeaderText = "Select All", .CheckBoxSize = New Size(15, 15), .TrueValue = "True", .FalseValue = "False"})
                                TryCast(Me.grdMain.Columns("Select All"), GridCheckBoxColumn).AllowCheckBoxOnHeader = True
                                Me.grdMain.Columns("Select All").HeaderText = String.Empty
                                Me.grdMain.Columns("Select All").AllowEditing = True
                                TryCast(Me.grdMain.Columns("Select All"), GridCheckBoxColumn).AllowText = True
                                grdMain.DataSource = ds.Tables(0)

                            Else
                                Dim info As New FrmInfoMsgBox
                                info.lblmsg.Text = "Sorry, No Records Available"
                                info.ShowDialog()
                            End If
                        End Using
                    End Using
                End Using
            End Using
        Catch ex As Exception
            IO.File.AppendAllText(appDataPath & "\Log.txt", String.Format("{0}{1}", Environment.NewLine, ex.ToString()))
            Dim x As New FrmErrorMsgBox
            x.txterrormsg.Text = ex.Message.ToString
            x.ShowDialog()
        End Try
    End Sub


--the above lines are loading statements in Sfdatagrid


 and now, i have to capture checked and unchecked status in for loop. And, I have to resize the panel if checked status is more than 0.

Private Sub grdMain_CellCheckBoxClick(sender As Object, e As CellCheckBoxClickEventArgs) Handles grdMain.CellCheckBoxClick
 If grdMain.CurrentCell.ColumnIndex = 0 Then
            grdMain.CurrentCell.CellRenderer.SetControlValue("True")
            Dim dt As New DataTable
            dt = grdMain.DataSource
            Dim x As Integer
            Call grdMain.CurrentCell.EndEdit()
            For Each row In dt.Rows
                If row("Select All") = "True" Then
                    x = x + 1
                End If
            Next
            MsgBox(x)
        End If
End sub

and, i have try this. it does captures the checked or unchecked status delayed. i mean the 'x' value is 0 even after clicking checkbox to 'True', the 'x' value returns '1' only after clicking next checkbox cell.
it should change 'x' as 1 when clicking the checkbox cell for the first time..

and, also sfdatagrid doesnot have CurrentCellValueChanged event.. and i do the same line of coding in CurrentCellValidating and CurrentCellEndEdit, it doesnot results anything

Amal Raj U [Syncfusion]
Replied On January 17, 2020 08:40 AM UTC

Hi Sulthan, 

Thanks for using Syncfusion products. 

Since CheckBoxColumn is non-editable, SfDataGrid doesn’t raise CurrentCellValidating and CurrentCellEndEdit events like editable columns. 

SfDataGrid raises CellCheckBoxClick event to notify the state of the checkbox that is about to change after clicking on checkbox and doesn’t modify the underlying value of the column on CellCheckBoxClick event. So, the modified value of the checkbox cell can’t be retrieved in CellCheckBoxClick event. 

If you want to retrieve the current modified value, then the View.RecordPropertyChanged event can be used. 

Code snippet: 
AddHandler Me.sfDataGrid1.View.RecordPropertyChanged, AddressOf OnRecordPropertyChanged 
 
 
Private Sub OnRecordPropertyChanged(ByVal sender As Object, ByVal e As PropertyChangedEventArgs) 
       If e.PropertyName = "IsClosed" Then 
              Dim isClosed = (TryCast(sender, OrderInfo)).IsClosed 
 
              'You can customize here. 
       End If 
End Sub 

Sample location: 

Regards, 
Amal Raj Umapathy Selvam. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon