How to get the specific column value for each checked rows in sfdatagrid
Private Sub btnDelete_Click(sender As Object, e As EventArgs) Handles btnDelete.Click
' Dim selectedRows = Me.grdMain.View.Records.Where(Function(item) TryCast(sender, DataRowView).Row("isClosed") = True).ToList
Dim selectedRowIndex As Integer
Dim records = grdMain.View.Records
Dim x As Integer = 0
For Each record In records
Dim dataRowView = TryCast(record.Data, DataRowView)
If dataRowView IsNot Nothing Then
Dim selected = dataRowView.Row("isClosed")
If selected.[GetType]() <> GetType(DBNull) AndAlso CBool(selected) Then
selectedRowIndex = selected.RowIndex
' Dim rowIndex As Integer = 2
Dim columnIndex As Integer = grdMain.TableControl.ResolveToGridVisibleColumnIndex(1)
If columnIndex < 0 Then
Return
End If
Dim recordIndex = grdMain.TableControl.ResolveToRecordIndex(selectedRowIndex)
If recordIndex < 0 Then
Return
End If
Dim record1 = grdMain.View.Records.GetItemAt(recordIndex)
If record1 IsNot Nothing Then
Dim cellValue = (TryCast(record1, DataRowView).Row.ItemArray(columnIndex))
Dim cellString = String.Empty
If cellValue IsNot Nothing Then
cellString = cellValue.ToString()
End If
MessageBox.Show(cellString)
End If
Else
End If
End If
Next
End Sub
When i click a button, i need to get specific column values on each row which is checked = True (isClosed = True)
SIGN IN To post a reply.
3 Replies
VS
Vijayarasan Sivanandham
Syncfusion Team
February 11, 2020 12:43 PM UTC
Hi Sulthan,
Thank you for contacting Syncfusion Support.
We have analyzed your query. Your requirement “to get specific column value when checked row is true"can be achieved by using SfDataGrid.View.Records. Please refer the below code snippet.
|
Private Sub BtnGetValue_Click(ByVal sender As Object, ByVal e As EventArgs)
txtColumnValue.Text = String.Empty
For Each records In sfDataGrid.View.Records
Dim datarowview = TryCast(records.Data, OrderInfo)
If datarowview.IsShipped = True Then
txtColumnValue.Text &= datarowview.CustomerName
End If
Next records
End Sub |
Please find sample for the same from the below link,
If we misunderstood your requirement, please provide more information regarding the requirement. This would help us to proceed further.
Regards,
Vijayarasan
Hi Sulthan,Thank you for contacting Syncfusion Support.We have analyzed your query. Your requirement “to get specific column value when checked row is true"can be achieved by using SfDataGrid.View.Records. Please refer the below code snippet.
Private Sub BtnGetValue_Click(ByVal sender As Object, ByVal e As EventArgs)txtColumnValue.Text = String.EmptyFor Each records In sfDataGrid.View.RecordsDim datarowview = TryCast(records.Data, OrderInfo)If datarowview.IsShipped = True ThentxtColumnValue.Text &= datarowview.CustomerNameEnd IfNext recordsEnd SubPlease find sample for the same from the below link,If we misunderstood your requirement, please provide more information regarding the requirement. This would help us to proceed further.Regards,Vijayarasan
Thanx for the help..
For Each record In grdMain.View.Records
Dim datarowview = TryCast(record.Data, DataRowView)
If datarowview IsNot Nothing Then
If datarowview.Row("isClosed") = True Then
cellString = datarowview.Row("Voucher No")
End If
End If
Next record
for me this runs what i expected..
FP
Farjana Parveen Ayubb
Syncfusion Team
February 24, 2020 05:44 AM UTC
Hi Sulthan,
Thanks for the update.
We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you.
Regards,
Farjana Parveen A
SIGN IN To post a reply.
- 3 Replies
- 3 Participants
-
SU sulthan
- Feb 10, 2020 02:14 PM UTC
- Feb 24, 2020 05:44 AM UTC