Results 1 to 7 of 7

Thread: How to hide MSHFlexgrid Subset rows[Resolved]

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2004
    Location
    Mumbai
    Posts
    236

    Resolved 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...
    Attached Images Attached Images  
    Last edited by kishore.kr; Jun 14th, 2005 at 12:05 AM. Reason: Closing the thread...

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Jul 2004
    Location
    Mumbai
    Posts
    236

    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...

  3. #3
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: How to hide MSHFlexgrid Subset rows

    You can try this code. It doesn't work if you have shaped the data.
    VB Code:
    1. Private Sub cmdExpandCollapse_Click()
    2.  
    3.    Dim i As Integer, r As Integer
    4.  
    5.    ' Ignore top row.
    6.    r = Me.MSHFlexGrid1.MouseRow
    7.    If r < 1 Then Exit Sub
    8.  
    9.    ' Find field to collapse or expand.
    10.    While r > 0 And Me.MSHFlexGrid1.TextArray(r * Me.MSHFlexGrid1.Cols) = ""
    11.       r = r - 1
    12.    Wend
    13.  
    14.    ' Show collapsed/expanded symbol on first column.
    15.    If Me.MSHFlexGrid1.TextArray(r * Me.MSHFlexGrid1.Cols) = "*" Then
    16.       Me.MSHFlexGrid1.TextArray(r * Me.MSHFlexGrid1.Cols) = "+"
    17.    Else
    18.       Me.MSHFlexGrid1.TextArray(r * Me.MSHFlexGrid1.Cols) = "*"
    19.    End If
    20.  
    21.    ' Expand items under current heading.
    22.    r = r + 1
    23.    If Me.MSHFlexGrid1.RowHeight(r) = 0 Then
    24.       Do While Me.MSHFlexGrid1.TextArray(r * Me.MSHFlexGrid1.Cols) = ""
    25.          Me.MSHFlexGrid1.RowHeight(r) = -1 ' Default row height.
    26.          r = r + 1
    27.          If r >= Me.MSHFlexGrid1.Rows Then Exit Do
    28.       Loop
    29.  
    30.    ' Collapse items under current heading.
    31.    Else
    32.       Do While Me.MSHFlexGrid1.TextArray(r * Me.MSHFlexGrid1.Cols) = ""
    33.          Me.MSHFlexGrid1.RowHeight(r) = 0   ' Hide row.
    34.          r = r + 1
    35.          If r >= Me.MSHFlexGrid1.Rows Then Exit Do
    36.       Loop
    37.    End If
    38. End Sub

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jul 2004
    Location
    Mumbai
    Posts
    236

    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...

  5. #5
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    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:
    1. Option Explicit
    2. Dim con As New ADODB.Connection
    3. Dim rst As New ADODB.Recordset
    4.  
    5. Private Sub Form_Load()
    6.     Dim sCmd As String
    7.    
    8. '    con.CursorLocation = adUseClient
    9.     con.Open "PROVIDER=MSDataShape;Data PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
    10.         "C:\Documents and Settings\Administrator\Desktop\Pradeep\TradeNotice" & "\tn.mdb;"
    11.     sCmd = "SHAPE {SELECT URL, FriendlyName, tableheaders FROM URL} " & _
    12.         "APPEND ({SELECT URL, FriendlyName,tableheaders FROM URL2} AS chapURL " & _
    13.         "RELATE tableheaders TO tableheaders )"
    14.     rst.StayInSync = False
    15.     rst.Open sCmd, con, adOpenStatic, adLockOptimistic
    16.     Set ParentGrid.Recordset = rst
    17.     ParentGrid.CollapseAll
    18. End Sub
    19.  
    20. Private Sub Form_Resize()
    21.     ParentGrid.Top = 0
    22.     ParentGrid.Left = 0
    23.     ParentGrid.Width = Me.ScaleWidth
    24.     ParentGrid.Height = Me.ScaleHeight
    25. End Sub
    26.  
    27. Private Sub ParentGrid_Collapse(Cancel As Boolean)
    28. ChildGrid(ParentGrid.Row).Visible = False
    29. End Sub
    30.  
    31. Private Sub ParentGrid_Expand(Cancel As Boolean)
    32.     Dim x As Long
    33.     x = ParentGrid.Row
    34.     On Error Resume Next
    35.     Load ChildGrid(x)
    36.     On Error GoTo 0
    37.     With ChildGrid(x)
    38.         'Set .Recordset = ...   '' Fill the child grid
    39.         .Move ParentGrid.ColPos(1), ParentGrid.RowPos(x) + ParentGrid.RowHeight(0)
    40.         ParentGrid.RowHeight(x) = ChildGrid(x).Height + ParentGrid.RowHeight(0)
    41.         .Visible = True
    42.         .ZOrder 0
    43.     End With
    44. End Sub
    45.  
    46. Private Sub Form_Unload(Cancel As Integer)
    47.     rst.Close
    48.     Set rst = Nothing
    49.     con.Close
    50.     Set con = Nothing
    51. End Sub
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jul 2004
    Location
    Mumbai
    Posts
    236

    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...

  7. #7
    New Member
    Join Date
    Apr 2008
    Posts
    13

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width