1 Attachment(s)
How to hide MSHFlexgrid Subset rows[Resolved]
hi guys,
i am using mshflexgrid in my application. i am using shape command and it works fine. but i want to give it realistic look. the one generated by vb is not like the one in MSAccess. In access you can see the hierarchical flexgrid of a Primary-Secondary tables in a good way. i wanted to give my application also the same feel.
so i used another mshflexgrid which will again retrieve only the child but the height setting of the main flexgrid is not getting accurate because i cannot set the height of the subset to 0.
i'll put my problem in simple words. i want to make my subset rows height to 0.(of band 1 in example). see the picture..
-- Kishore...
Re: How to hide MSHFlexgrid Subset rows
i can set the column width to 0 but that does not solve my problem. i specifically have to set the height of the child rows to 0. it will be very helpful if anyone give me useful ideas or suggesstions.. thank you.
Kishore...
Re: How to hide MSHFlexgrid Subset rows
You can try this code. It doesn't work if you have shaped the data.
VB Code:
Private Sub cmdExpandCollapse_Click()
Dim i As Integer, r As Integer
' Ignore top row.
r = Me.MSHFlexGrid1.MouseRow
If r < 1 Then Exit Sub
' Find field to collapse or expand.
While r > 0 And Me.MSHFlexGrid1.TextArray(r * Me.MSHFlexGrid1.Cols) = ""
r = r - 1
Wend
' Show collapsed/expanded symbol on first column.
If Me.MSHFlexGrid1.TextArray(r * Me.MSHFlexGrid1.Cols) = "*" Then
Me.MSHFlexGrid1.TextArray(r * Me.MSHFlexGrid1.Cols) = "+"
Else
Me.MSHFlexGrid1.TextArray(r * Me.MSHFlexGrid1.Cols) = "*"
End If
' Expand items under current heading.
r = r + 1
If Me.MSHFlexGrid1.RowHeight(r) = 0 Then
Do While Me.MSHFlexGrid1.TextArray(r * Me.MSHFlexGrid1.Cols) = ""
Me.MSHFlexGrid1.RowHeight(r) = -1 ' Default row height.
r = r + 1
If r >= Me.MSHFlexGrid1.Rows Then Exit Do
Loop
' Collapse items under current heading.
Else
Do While Me.MSHFlexGrid1.TextArray(r * Me.MSHFlexGrid1.Cols) = ""
Me.MSHFlexGrid1.RowHeight(r) = 0 ' Hide row.
r = r + 1
If r >= Me.MSHFlexGrid1.Rows Then Exit Do
Loop
End If
End Sub
Re: How to hide MSHFlexgrid Subset rows
hi dglienna,
i am using shape commands only. if you know any way to solve the row hiding problem in shape command itself then please do reply. if there is no way then i should try the other way of directly using select command for each bands. thank you for the suggesstion .
- Kishore...
Re: How to hide MSHFlexgrid Subset rows
Quote:
Originally Posted by kishore.kr
hi dglienna,
i am using shape commands only. if you know any way to solve the row hiding problem in shape command itself then please do reply. if there is no way then i should try the other way of directly using select command for each bands. thank you for the suggesstion .
- Kishore...
Hi,
I was trying to achieve a similar thing. But due to time constraint, I shifted over to GridView control. Here is the code that is working till the point you want. It uses the shape command. Just develop it furthur.
On the form it is a MSHGrid named ParentGrid and another named ChildGrid (with index 0).
VB Code:
Option Explicit
Dim con As New ADODB.Connection
Dim rst As New ADODB.Recordset
Private Sub Form_Load()
Dim sCmd As String
' con.CursorLocation = adUseClient
con.Open "PROVIDER=MSDataShape;Data PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
"C:\Documents and Settings\Administrator\Desktop\Pradeep\TradeNotice" & "\tn.mdb;"
sCmd = "SHAPE {SELECT URL, FriendlyName, tableheaders FROM URL} " & _
"APPEND ({SELECT URL, FriendlyName,tableheaders FROM URL2} AS chapURL " & _
"RELATE tableheaders TO tableheaders )"
rst.StayInSync = False
rst.Open sCmd, con, adOpenStatic, adLockOptimistic
Set ParentGrid.Recordset = rst
ParentGrid.CollapseAll
End Sub
Private Sub Form_Resize()
ParentGrid.Top = 0
ParentGrid.Left = 0
ParentGrid.Width = Me.ScaleWidth
ParentGrid.Height = Me.ScaleHeight
End Sub
Private Sub ParentGrid_Collapse(Cancel As Boolean)
ChildGrid(ParentGrid.Row).Visible = False
End Sub
Private Sub ParentGrid_Expand(Cancel As Boolean)
Dim x As Long
x = ParentGrid.Row
On Error Resume Next
Load ChildGrid(x)
On Error GoTo 0
With ChildGrid(x)
'Set .Recordset = ... '' Fill the child grid
.Move ParentGrid.ColPos(1), ParentGrid.RowPos(x) + ParentGrid.RowHeight(0)
ParentGrid.RowHeight(x) = ChildGrid(x).Height + ParentGrid.RowHeight(0)
.Visible = True
.ZOrder 0
End With
End Sub
Private Sub Form_Unload(Cancel As Integer)
rst.Close
Set rst = Nothing
con.Close
Set con = Nothing
End Sub
Re: How to hide MSHFlexgrid Subset rows
hi guys,
thanks for the ideas. i developed my module from your ideas and i got what i required. thanks a lot especially(dglienna, pradeep).. i have planned to develop it further and make an ocx(in future..).
-- Kishore...
Re: How to hide MSHFlexgrid Subset rows[Resolved]
Iam facing the grouping problem and tried your code have error in executing
'Invalid Sql Statment expected insert,delete,select or update'
if you please provide an example or write more details
Thanks