[RESOLVED] MsFlexGrid Select Only 1 row at time.-VBForums
Results 1 to 15 of 15

Thread: [RESOLVED] MsFlexGrid Select Only 1 row at time.

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2003
    Location
    Out there somewhere!
    Posts
    386

    Resolved [RESOLVED] MsFlexGrid Select Only 1 row at time.

    I am using a MSFlexGrid. Is there a quick and easy way to stop the user selecting more than one row at a time. I want the user to only be allowed to select one row.

    Thanks

    Kev

    Albert Einstein - "The secret to creativity is knowing how to hide your sources."

  2. #2
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: MsFlexGrid Select Only 1 row at time.

    i think you cant do that
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  3. #3
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: MsFlexGrid Select Only 1 row at time.

    yes, in the msflexgrid set the follow

    FillStyle=0-Single
    SelectionMode=1=By Row
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2003
    Location
    Out there somewhere!
    Posts
    386

    Re: MsFlexGrid Select Only 1 row at time.

    Hello ganeshmoorthy

    unfortunately that is what I have already set. You still can select more than one row by dragging the mouse or using the shift key.

    Is there anyway to disable this.


    Kev.

    Steve Martin - "A day without sunshine is like, you know, night"

  5. #5
    New Member Marvels's Avatar
    Join Date
    Jan 2006
    Location
    Amsterdam
    Posts
    8

    Re: MsFlexGrid Select Only 1 row at time.

    HI

    If you right click the grid and select propertys or in propertyscreen(F4) you have the custom property
    there you see

    if you set the checkbox off where it says Allowbigselecion
    and the selectionmode would help if you set it by Row


  6. #6
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: MsFlexGrid Select Only 1 row at time.

    I'm sorry for that please also
    set the MergeCells =2-RestrictRows
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2003
    Location
    Out there somewhere!
    Posts
    386

    Re: MsFlexGrid Select Only 1 row at time.

    Thanks again, setting the property MergeCells =2-RestrictRows does, sort of work. The only problem I have now is that the row the user clicks on isn't highlighted.

    Kev

    Steven Wright - "It's a small world, but I wouldn't want to paint it. "

  8. #8
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: MsFlexGrid Select Only 1 row at time.

    is a cell getting highlighted
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2003
    Location
    Out there somewhere!
    Posts
    386

    Re: MsFlexGrid Select Only 1 row at time.

    It doesn't look like anything is getting highlighted.

    I have written a small procedure on the click event that highlights the row selected. Just seems a lot of work.

    Oh well.


    Kev.

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2003
    Location
    Out there somewhere!
    Posts
    386

    Re: MsFlexGrid Select Only 1 row at time.

    Marvels

    Had AllowBigSelection set to false and SelectionByRow, it didn't work, still allowed the user to select more than one row by dragging the mouse or using the shift key.


    Thanks

    Kev.

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2003
    Location
    Out there somewhere!
    Posts
    386

    Re: MsFlexGrid Select Only 1 row at time.

    Marvels

    Had AllowBigSelection set to false and SelectionByRow, it didn't work, still allowed the user to select more than one row by dragging the mouse or using the shift key.


    Thanks

    Kev

  12. #12
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: MsFlexGrid Select Only 1 row at time.

    no matter what happens when you drag your cursor and highlight a lot of cells or rows, it is only the highlight that does it but in the selection sense, only one record will be selected. i'm sure of this,

    the problem with this truth is that the user can be confused with the number of rows he selected

    i have a proposal or shall we say, a suggestion for Kev, if you really want to select only a single row at a time, try to use listview

    i know it very much that it is posible with listview coz thats the way all my applications work. try it and youll see your desired result.

    i for myself will conclude that theres no way you can restrict the user to be able to highlight a single row only with msflexgrid. i dont know with the others, i would be glad if somebody could correct me if theres a way,


    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  13. #13
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: MsFlexGrid Select Only 1 row at time.

    VB Code:
    1. flexgrid.SelectionMode = flexSelectionByRow

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2003
    Location
    Out there somewhere!
    Posts
    386

    Re: MsFlexGrid Select Only 1 row at time.

    I have it working so that only one row is selected. The only way I could do it was as ganeshmoorthy suggested and then on the click event I manually highlighted the through VB Code as below.

    Code:
    Private Sub grdEstimatesFound_Click()
        Dim i As Integer
        Dim j As Integer
        Dim intRow As Integer
        
        With grdEstimatesFound
            intRow = .Row
            
            For j = 1 To .Rows - 1
                .Row = j
                If j = intRow Then
                    For i = 0 To .Cols - 1
                        .Col = i
                        .CellBackColor = vbHighlight
                        .CellForeColor = vbWhite
                    Next i
                Else
                    For i = 0 To .Cols - 1
                        .Col = i
                        .CellBackColor = vbWhite
                        .CellForeColor = vbBlack
                    Next i
                End If
            Next j
            
            .Row = intRow
        End With
        
        DoEvents
                
    End Sub
    That is the only way I could do it.


    Kev.

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

    Re: [RESOLVED] MsFlexGrid Select Only 1 row at time.

    This is what I use

    VB Code:
    1. Private Sub MSFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    2.     If Button = vbLeftButton Then
    3.         'Turns off the automatic Highlighting and colors the current row's
    4.         'background with the highlight color
    5.         With Me.MSFlexGrid1
    6.             .Redraw = False
    7.             .FillStyle = flexFillRepeat
    8.             .RowSel = .Row
    9.             .ColSel = .Cols - 1
    10.             .CellBackColor = .BackColorSel
    11.             .HighLight = flexHighlightNever
    12.             .FillStyle = flexFillRepeat
    13.             .Redraw = True
    14.         End With
    15.     End If
    16. End Sub
    17.  
    18. Private Sub MSFlexGrid1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
    19.     If Button = vbLeftButton Then
    20.         'Turns ON automatic Highlighting and resets the current row's
    21.         'background color to the default
    22.         With Me.MSFlexGrid1
    23.             .Redraw = False
    24.             .FillStyle = flexFillRepeat
    25.             .RowSel = .Row
    26.             .ColSel = .Cols - 1
    27.             .CellBackColor = .BackColor
    28.             .HighLight = flexHighlightAlways
    29.             .Redraw = True
    30.         End With
    31.     End If
    32. End Sub
    33.  
    34. Private Sub MSFlexGrid1_SelChange()
    35.     MSFlexGrid1.RowSel = MSFlexGrid1.Row
    36. End Sub
    37.  
    38. Private Sub Form_Load()
    39.     With MSFlexGrid1
    40.         .AllowBigSelection = False
    41.         .AllowUserResizing = flexResizeColumns
    42.         .Cols = 5
    43.         .Rows = 10
    44.         .SelectionMode = flexSelectionByRow
    45.         .FocusRect = flexFocusNone
    46.     End With
    47. End Sub

    This also works

    VB Code:
    1. Private Sub MSFlexGrid1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    2.     If Button = vbLeftButton Then
    3.         MSFlexGrid1.Redraw = False
    4.     End If
    5. End Sub
    6.  
    7. Private Sub MSFlexGrid1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    8.     If Button = vbLeftButton Then
    9.         MSFlexGrid1.Redraw = True
    10.     End If
    11. End Sub
    12.  
    13. Private Sub MSFlexGrid1_SelChange()
    14.     MSFlexGrid1.RowSel = MSFlexGrid1.Row
    15. End Sub
    Last edited by brucevde; Jan 27th, 2006 at 01:28 PM.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.