C1Flexgrid Warp Cell

Posted by: saidnai on 22 February 2023, 12:35 am EST

  • Posted 22 February 2023, 12:35 am EST

    Hi all,

    I am using the following code for filling the C1Flexgrid :

    SqlStr = “SELECT Field1, Field2, Field3, Field4, Field5, Field6, Field7 FROM TableX ORDER BY Field1”

    Dim Odbcda As New Odbc.OdbcDataAdapter(SqlStr, connectionString)

    odbcDataSet = New DataSet

    Odbcda.Fill(odbcDataSet, “Liste”)

    Dim dt As DataTable = odbcDataSet.Tables(“Liste”)

    DGAAV.DataSource = dt

    With C1Flexgrid

    .Cols(1).Caption = “Field1”

    .Cols(1).Width = 80

    .Cols(1).TextAlign = TextAlignEnum.LeftTop

    .Cols(4).Caption = “Field2”

    .Cols(4).Width = 160

    .Cols(4).TextAlign = TextAlignEnum.LeftTop

    .Cols(5).Caption = “Field3”

    .Cols(5).Width = 80

    .Cols(5).TextAlign = TextAlignEnum.LeftTop

    .Cols(6).Caption = “Field4”

    .Cols(6).Width = 160

    .Cols(6).TextAlign = TextAlignEnum.LeftTop

    .Cols(7).Caption = “Field5”

    .Cols(7).Width = 160

    .Cols(7).TextAlign = TextAlignEnum.LeftTop

    .Cols(8).Caption = “Field6”

    .Cols(8).Width = 75

    .Cols(8).Format = “#”

    .Cols(8).TextAlign = TextAlignEnum.RightTop

    .Cols(9).Caption = “Field7”

    .Cols(9).Width = 60

    .Cols(9).TextAlign = TextAlignEnum.LeftTop

    DGAAV.Select(-1, -1)


    Catch ex As Exception

    MsgBox("Error ‘ShowLA’ : " & vbCrLf & ex.ToString, MsgBoxStyle.Critical)

    End Try

    End Sub

    Sub WrapCell()


    Dim cellStyleWrapped As CellStyle = Me.C1Flexgrid.Styles.Add(“Wrapped”, Me.C1Flexgrid.Styles.Normal)

    cellStyleWrapped.WordWrap = True

        Dim rw As Integer = 0
        For Each r As Row In C1FlexGrid.Rows
            Me.C1Flexgrid.SetCellStyle(rw, 0, cellStyleWrapped)
            Me.C1Flexgrid.SetCellStyle(rw, 1, cellStyleWrapped)
            Me.C1Flexgrid.SetCellStyle(rw, 3, cellStyleWrapped)
            Me.C1Flexgrid.SetCellStyle(rw, 4, cellStyleWrapped)
            Me.C1Flexgrid.SetCellStyle(rw, 6, cellStyleWrapped)
            Me.C1Flexgrid.SetCellStyle(rw, 7, cellStyleWrapped)
            rw += 1
    Catch ex As Exception
        MsgBox("Error 'WrapCell' : " & vbCrLf & ex.ToString, MsgBoxStyle.Critical)
        'Cursor.Current = Cursors.Default
    End Try

    End Sub

    It is working fine for showing the data.

    The problem is the function wrapCell. After loading 58879 records in the C1Felxgrid the application is block and i have to kill the application process over task manager. It takes a lot of time to wrap the cells for all of the 58879 records.

    Is there a better way to the WrapCell quickly?

    Best reagrds


  • Posted 22 February 2023, 11:13 pm EST

    Hello Said,

    As you are assigning the CellStyle object to each cell and you have 58879 records so it might cause a performance issue. You can directly assign the particular style to your particular columns directly instead of assigning it to each cell.

    Please see the attached stripped-down sample implementing the same and let us know if the issue still occurs with it.


    Prabhat Sharma.


  • Posted 23 February 2023, 10:07 pm EST

    Dear Prabhat,

    The permance still suffering under the new way. If there is another way to load the Flexgrid and the Wrap Cell is quicklier let me know.

    The Flexgrid will only show some data. after doubleClick on the row. The detail will shown in another form.

    Maybe there is a Flexgrid sample code to do it with pages (previous X records / next X records)

    Best regards


  • Posted 24 February 2023, 12:02 am EST

    Hi Said,

    before filling the grid, call “Me.C1Flexgrid = false”. Set it to true again after filling is done. This should improve performance a lot.

    Best regards


  • Posted 24 February 2023, 2:20 am EST

    Dear Wolfgang,

    Thank you for your support.

    Can you please point in the code on the top the exact call function?

    Best regards


  • Posted 24 February 2023, 2:34 am EST

    You can call “Redraw = false” at the beginning and “Redraw = true” at the end of your code snippet.

    Best regards


Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels