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)
WrapCell()
Catch ex As Exception
MsgBox("Error ‘ShowLA’ : " & vbCrLf & ex.ToString, MsgBoxStyle.Critical)
End Try
End Sub
Sub WrapCell()
Try
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) Me.C1Flexgrid.AutoSizeRow(rw) rw += 1 Next Catch ex As Exception MsgBox("Error 'WrapCell' : " & vbCrLf & ex.ToString, MsgBoxStyle.Critical) Finally '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
Said