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 modify the existing column type which is loaded from Datasets(through SQLDataAdapter)

Thread ID:

Created:

Updated:

Platform:

Replies:

150785 Jan 20,2020 07:40 AM UTC Jan 20,2020 09:01 AM UTC WinForms 1
loading
Tags: SfDataGrid
sulthan
Asked On January 20, 2020 07:40 AM UTC

  Public constring As String = AlgoMdConnectionString       
 Try
            Using con As New SqlConnection(constring)
                Using cmd As New SqlCommand("SELECT
TAP_BillDate AS [Bill Date],
'False' AS [isClosed],
TAP_Payable AS [Balance],
'' AS [Payment]
from Tbl_AccPending 
", con)
                    cmd.CommandType = CommandType.Text
                    Using sda As New SqlDataAdapter(cmd)
                        Using ds As New DataSet()
                            sda.Fill(ds)
                               SfDataGrid1.DataSource = ds.Tables(0)
                                'SfDataGrid1.Columns.Add(New GridCheckBoxColumn() With {.MappingName = "isClosed", .HeaderText = "isClosed", .CheckBoxSize = New Size(15, 15), .TrueValue = "True", .FalseValue = "False"})

                                    
                        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()))
       End Try

on the above SQL Commands i have to modify 'isClosed' column as CheckBoxColumn .. i try SfDataGrid1.Columns.Add(New GridCheckBoxColumn() , but it creating new checkbox column at the end of all columns.. But i needs to modify the existing column loads from dataset at its same position.. if u have any other way to solve this, please let me know..

--regards
Sulthan

Farjana Parveen Ayubb [Syncfusion]
Replied On January 20, 2020 09:01 AM UTC

Hi Sulthan, 
 
Thank you for using Syncfusion controls. 
 
You can modify the existing column type in SfDataGrid.AutoGeneratingColumns event. Please refer the below code example, 
 
AddHandler sfDataGrid.AutoGeneratingColumn, AddressOf SfDataGrid_AutoGeneratingColumn 
sfDataGrid.DataSource = employeeCollection 
 
Private Sub SfDataGrid_AutoGeneratingColumn(ByVal sender As Object, ByVal e As AutoGeneratingColumnArgs) 
       If e.Column.MappingName = "IsClosed" Then 
              e.Column = New GridCheckBoxColumn() With {.MappingName = "IsClosed", .HeaderText = "Is Closed"} 
       End If 
End Sub 
 
 
 
Please let us know if you need any further details on this. 
 
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