I am using C1FlexGrid and I set the data table as c1flexgrid's data source. now I want to map filed of data table to columns of c1flexgrid by code. please tell me how to do it.
            Asked
            
        
        
            Active
            
        
            Viewed 6,414 times
        
    3
            
            
        
        Vivek S.
        
- 19,945
 - 7
 - 68
 - 85
 
        Dr. Rajesh Rolen
        
- 14,029
 - 41
 - 106
 - 178
 
1 Answers
4
            To programmatically create columns on the C1FlexGrid:
 - Set AutoGenerateColumns to False 
 - Add column definitions to the C1FlexGridBase.Cols() collection. 
 - Bind the DataTable to the flexgrid
For example,
Private _dt As System.Data.DataTable
Private Sub LoadFlexGrid()
    'create new table
    _dt = New System.Data.DataTable("MyDataTable")
    _dt.Columns.Add("CustomerId", GetType(Integer))
    _dt.Columns.Add("CustomerName", GetType(String))
    'populate it
    _dt.Rows.Add(New Object() {12, "Joe"})
    _dt.Rows.Add(New Object() {14, "Bob"})
    'define column grid columns
    Dim col1 As C1.Win.C1FlexGrid.Column
    col1 = flex.Cols.Add()
    col1.Name = "CustomerId"
    col1.Caption = "Customer Id"
    Dim col2 As C1.Win.C1FlexGrid.Column
    col2 = flex.Cols.Add()
    col2.Name = "CustomerName"
    col2.Caption = "Name"
    'bind the grid to it
    flex.AutoGenerateColumns = False
    flex.DataSource = _dt
End Sub
        user335161
        
- 56
 - 3