Hi.
I am using vb6 to pull information from a db using the Shape sql format so that I can get grouped data. But theres something weird going on.
It pulls the data through, but if I try to adjust the colwidth throu code, then the grid gets messed up.
Heres the code:
Code:Private Const MARGIN_SIZE = 60 ' in Twips ' variables for data binding Private datPrimaryRS As ADODB.Recordset Private Sub Command1_Click() With MSHFlexGrid1 .ColWidth(3) = 1000 End With End Sub Private Sub Form_Load() Dim sConnect As String Dim sSQL As String Dim dfwConn As ADODB.Connection Dim i As Integer Dim s As String ' set strings sConnect = "PROVIDER=MSDataShape;Extended Properties='DRIVER=SQL Server;SERVER=xserver;UID=user1;PWD=user1;APP=Visual Basic;WSID=xserver;DATABASE=xdb'" sSQL = "SHAPE {SELECT ZoneIndex, ZoneName FROM tblZones} AS Command1 APPEND ({SELECT DeviceIndex, DeviceAddress, Name, HeartBeat, ZoneIndex FROM tblDeviceDetails} AS Command2 RELATE 'ZoneIndex' TO 'ZoneIndex') AS Command2" ' open connection Set dfwConn = New Connection dfwConn.Open sConnect ' create a recordset using the provided collection Set datPrimaryRS = New Recordset datPrimaryRS.CursorLocation = adUseClient datPrimaryRS.Open sSQL, dfwConn, adOpenForwardOnly, adLockReadOnly s = "|ZoneIndex|ZoneName|DeviceIndex|Device Address|Name|Heartbeat" MSHFlexGrid1.FormatString = s Set MSHFlexGrid1.DataSource = datPrimaryRS 's = "" With MSHFlexGrid1 .Redraw = False ' set grid's column widths '.FormatString = s .ColWidth(0) = 300 '.ColWidth(1) = 300 '.ColWidth(2) = 300 '.ColWidth(3) = 300 '.ColWidth(4) = 2000 '.ColWidth(5) = -1 '.ColWidth(6) = -1 '.ColWidth(7) = -1 '.ColWidth(8) = -1 '.ColWidth(9) = -1 '.ColWidth(10) = -1 '.ColWidth(11) = -1 '.ColWidth(12) = -1 '.ColWidth(13) = -1 '.ColWidth(14) = -1 '.ColWidth(15) = -1 '.ColWidth(16) = -1 '.ColWidth(17) = -1 '.ColWidth(18) = -1 '.ColWidth(19) = -1 '.ColWidth(20) = -1 '.ColWidth(21) = -1 '.ColWidth(22) = -1 '.ColWidth(23) = -1 '.ColWidth(24) = -1 '.ColWidth(25) = -1 '.ColWidth(26) = -1 '.ColWidth(27) = -1 '.ColWidth(28) = -1 ' set grid's column merging and sorting 'For i = 0 To .Cols - 1 ' .MergeCol(i) = True 'Next i '.Sort = flexSortGenericAscending ' set grid's style .AllowBigSelection = True .FillStyle = flexFillRepeat ' make header bold .Row = 0 .Col = 0 .RowSel = .FixedRows - 1 .ColSel = .Cols - 1 .CellFontBold = True .AllowBigSelection = False .FillStyle = flexFillSingle .Row = 4 .RowSel = 2 .Col = 4 .ColSel = 2 .CellBackColor = vbRed .CellPictureAlignment = flexAlignRightCenter Set .CellPicture = LoadPicture("C:\Program Files\Microsoft Visual Studio\Common\Graphics\Icons\Arrows\point15.ico") .Redraw = True .CollapseAll .ExpandAll .MergeCells = flexMergeNever End With End Sub
I have attached some pictures of whats happening:
Pic1 is when the load first loads.
Pic2 is when I click command1 to change the column width
Pic3 is when I collaspe zone1
Pic4 is when I expand it again.
As you can see, Now a new blank column has appeared outta nowhere.
I cant explain it.
Anyone have idea of whats going on?
Thanks.




Reply With Quote