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

How to get the specific column value for each checked rows in sfdatagrid

Thread ID:

Created:

Updated:

Platform:

Replies:

151397 Feb 10,2020 02:14 PM UTC Feb 24,2020 05:44 AM UTC WinForms 3
loading
Tags: SfDataGrid
sulthan
Asked On February 10, 2020 02:14 PM UTC

    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)



Vijayarasan Sivanandham [Syncfusion]
Replied On 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   


sulthan
Replied On February 21, 2020 06:26 AM 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   


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..

Farjana Parveen Ayubb [Syncfusion]
Replied On 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 


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