Results 1 to 7 of 7

Thread: MSFLEXGRID - Selecting Row with Merge

  1. #1

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Question MSFLEXGRID - Selecting Row with Merge

    Hi

    How can I to do it :


    When the user to Click a row, to select the Row , Where there are rows that were merged


    How can I to Delete the row selectioned ?


    Thank you in advance
    Attached Images Attached Images  

  2. #2
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: MSFLEXGRID - Selecting Row with Merge

    VB Code:
    1. MSFlexGrid1.RemoveItem MSFlexGrid1.Row

  3. #3

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Re: MSFLEXGRID - Selecting Row with Merge

    Hi, tks

    But It removed only 1 row , I want to remove 3 rows

  4. #4
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    266

    Re: MSFLEXGRID - Selecting Row with Merge

    r the three rows selected...if yes then u need to loop thru grid and check for selected rows and delete them

  5. #5

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Re: MSFLEXGRID - Selecting Row with Merge

    tKS

    btw - Do you Have a example ?
    How can I know if row is selected ?
    How can I do to all columns show with background other collor when the row is selected ?


    TIA

  6. #6
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: MSFLEXGRID - Selecting Row with Merge

    How can I do to all columns show with background other collor when the row is selected ?
    In another thread that you started there was a suggestion to insert a Hidden blank row between each group (so columns in different groups are not merged). http://www.vbforums.com/showthread.php?t=404776

    If you are using this suggestion then use the following code to highlight the selected group of merged rows.

    Basically, you find the the first hidden blank row before and after the current row. These become your Row and RowSel values. Then just colour all cells in the range.

    VB Code:
    1. Private Sub MSFlexGrid1_SelChange()
    2.     Dim lngStartRow As Long
    3.     Dim lngEndRow As Long
    4.    
    5.     With Me.MSFlexGrid1
    6.         .Redraw = False
    7.         lngEndRow = Me.MSFlexGrid1.Row
    8.         Do
    9.             If lngEndRow = .Rows - 1 Then Exit Do
    10.             If .TextMatrix(lngEndRow + 1, 0) = "" Then Exit Do
    11.             lngEndRow = lngEndRow + 1
    12.    
    13.         Loop
    14.    
    15.         lngStartRow = .Row
    16.         Do
    17.             If lngStartRow = .FixedRows Then Exit Do
    18.             If .TextMatrix(lngStartRow - 1, 0) = "" Then Exit Do
    19.             lngStartRow = lngStartRow - 1
    20.         Loop
    21.    
    22.         'remove the highlighting of the previously selected group
    23.         .FillStyle = flexFillRepeat
    24.         .Row = .FixedRows
    25.         .Col = 0
    26.         .RowSel = .Rows - 1
    27.         .ColSel = .Cols - 1
    28.         .CellBackColor = .BackColor
    29.        
    30.         'highlight the newly selected group
    31.         .Row = lngStartRow
    32.         .Col = .FixedCols
    33.         .ColSel = .Cols - 1
    34.         .RowSel = lngEndRow
    35.         .CellBackColor = .BackColorSel
    36.         .FillStyle = flexFillSingle
    37.         .Redraw = True
    38.     End With
    39.  
    40. End Sub

    Code to initialize the grid for testing...

    VB Code:
    1. Private Sub Form_Load()
    2.     With Me.MSFlexGrid1
    3.         .Cols = 4
    4.         .Rows = 10
    5.         .FixedCols = 0
    6.        
    7.         .TextMatrix(1, 0) = "A"
    8.         .TextMatrix(1, 1) = "XXX"
    9.         .TextMatrix(1, 2) = "1"
    10.         .TextMatrix(1, 3) = "12.00"
    11.    
    12.         .TextMatrix(2, 0) = "A"
    13.         .TextMatrix(2, 1) = "YYY"
    14.         .TextMatrix(2, 2) = "1"
    15.         .TextMatrix(2, 3) = "12.00"
    16.        
    17.         .TextMatrix(3, 0) = "A"
    18.         .TextMatrix(3, 1) = "ZZZ"
    19.         .TextMatrix(3, 2) = "1"
    20.         .TextMatrix(3, 3) = "12.00"
    21.    
    22.         .RowHeight(4) = 0
    23.        
    24.         .TextMatrix(5, 0) = "B"
    25.         .TextMatrix(5, 1) = "ZZZ"
    26.         .TextMatrix(5, 2) = "2"
    27.         .TextMatrix(5, 3) = "12.00"
    28.        
    29.         .TextMatrix(6, 0) = "B"
    30.         .TextMatrix(6, 1) = "ZZZ"
    31.         .TextMatrix(6, 2) = "1"
    32.         .TextMatrix(6, 3) = "12.00"
    33.        
    34.         .RowHeight(7) = 0
    35.        
    36.         .TextMatrix(8, 0) = "C"
    37.         .TextMatrix(8, 1) = "XXX"
    38.         .TextMatrix(8, 2) = "2"
    39.         .TextMatrix(8, 3) = "12.00"
    40.    
    41.         .TextMatrix(9, 0) = "C"
    42.         .TextMatrix(9, 1) = "YYY"
    43.         .TextMatrix(9, 2) = "2"
    44.         .TextMatrix(9, 3) = "13.00"
    45.        
    46.        
    47.         .MergeCells = flexMergeRestrictColumns
    48.         .MergeCol(0) = True
    49.         .MergeCol(2) = True
    50.         .MergeCol(3) = True
    51.         Call MSFlexGrid1_SelChange
    52.     End With
    53. End Sub
    Last edited by brucevde; May 12th, 2006 at 10:43 AM. Reason: Added link to another thread

  7. #7

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Question Re: MSFLEXGRID - Selecting Row with Merge

    Thanks

    I build other project with your solution, WORK FINE , but when I put inside my Original project not work

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