fg - VSFlexGrid
rcd - рекордсет (ADODB.Recordset)
cn - соединение с базой данных (ADODB.Connection)
Sub RefreshVSFlexGrid()
fg.Redraw = flexRDNone
On Error GoTo err1
sq = "SELECT * FROM r_Prods"
rcd.Open sq, cn, adOpenStatic
With fg
Set .DataSource = rcd
.Cell(flexcpAlignment, 0, 0, 0, .Cols - 1) = flexAlignCenterCenter
.RowHeight(0) = 400
For i = .FixedCols To .Cols - 1
.ColHidden(i) = True
Next i
.ColHidden(.ColIndex("ProdID")) = False
.ColHidden(.ColIndex("ProdName")) = False
.ColPosition(.ColIndex("ProdID")) = 1
.ColPosition(.ColIndex("ProdName")) = 2
.TextMatrix(0, .ColIndex("ProdID")) = "Код"
.TextMatrix(0, .ColIndex("ProdName")) = "Товар"
.ColWidth(.ColIndex("ProdID")) = 900
.ColWidth(.ColIndex("ProdName")) = 2000
End With
fg.Redraw = flexRDDirect
Screen.MousePointer = 0
Exit Sub
err1:
fg.Redraw = flexRDDirect
Screen.MousePointer = 0
MsgBox "Случилась ошибка!" & Chr(13) & err.Description, vbCritical, "Сообщение"
End Sub
rcd - рекордсет (ADODB.Recordset)
cn - соединение с базой данных (ADODB.Connection)
Sub RefreshVSFlexGrid()
fg.Redraw = flexRDNone
On Error GoTo err1
sq = "SELECT * FROM r_Prods"
rcd.Open sq, cn, adOpenStatic
With fg
Set .DataSource = rcd
.Cell(flexcpAlignment, 0, 0, 0, .Cols - 1) = flexAlignCenterCenter
.RowHeight(0) = 400
For i = .FixedCols To .Cols - 1
.ColHidden(i) = True
Next i
.ColHidden(.ColIndex("ProdID")) = False
.ColHidden(.ColIndex("ProdName")) = False
.ColPosition(.ColIndex("ProdID")) = 1
.ColPosition(.ColIndex("ProdName")) = 2
.TextMatrix(0, .ColIndex("ProdID")) = "Код"
.TextMatrix(0, .ColIndex("ProdName")) = "Товар"
.ColWidth(.ColIndex("ProdID")) = 900
.ColWidth(.ColIndex("ProdName")) = 2000
End With
fg.Redraw = flexRDDirect
Screen.MousePointer = 0
Exit Sub
err1:
fg.Redraw = flexRDDirect
Screen.MousePointer = 0
MsgBox "Случилась ошибка!" & Chr(13) & err.Description, vbCritical, "Сообщение"
End Sub