error on grdMain_CellCheckBoxClick() event to capture checked and unchecked value
'---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
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
SIGN IN To post a reply.
1 Reply
AR
Amal Raj U
Syncfusion Team
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.
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
SU sulthan
- Jan 16, 2020 08:24 AM UTC
- Jan 17, 2020 08:40 AM UTC