Results 1 to 4 of 4

Thread: [RESOLVED] MSHFlexGrid. Select single cell only

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2003
    Posts
    28

    Resolved [RESOLVED] MSHFlexGrid. Select single cell only

    Hi
    How can I force the user to be only able to select a single cell in a MSHFlexGrid?

    Currently they can click on a cell and then by holding the shift and selecting cursor keys they can select more than one cell at a time.

    Thanks in advance

  2. #2
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: MSHFlexGrid. Select single cell only

    Bob

    I have no experience in that regard, but perhaps you could
    add the corresponding events to "detect" those situations,
    and then add code in those events to essentially override what
    would have otherwise normally occurred.

    Spoo

  3. #3
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: MSHFlexGrid. Select single cell only

    Bob

    OK, I now have a little experience

    Maybe something like this:

    Code:
    Private Sub FG1_KeyDown(KeyCode As Integer, Shift as Integer)
        If Shift = 1 Then
            If KeyCode = 40 Then    ' down arrow
                v1 = FG1.MouseRow
                FG1.RowSel = v1
            End If
        End If
    End Sub
    The concept is to reset the RowSel (selected row) to always
    be where the mouse pointer is (MouseRow), effectively killing
    the effect of the down arrow key.

    Hope that gives you something to play with.

    Spoo

  4. #4
    Lively Member Stupidiot's Avatar
    Join Date
    Apr 2011
    Location
    India
    Posts
    95

    Re: MSHFlexGrid. Select single cell only

    'Assumptions
    'The grid is used for display purpose only
    'Want to focus always in a single cell
    'No other functions in the following events
    'Demo 5:5 Rows:Cols

    Code:
    Private Sub MSHFlexGrid1_EnterCell()
    With MSHFlexGrid1
    .HighLight = flexHighlightNever
    .FocusRect = flexFocusHeavy
    .Col = 4 ' change to desired Col
    .Row = 2 ' change to desired Row
    End With
    End Sub
    
    Private Sub MSHFlexGrid1_GotFocus()
    MSHFlexGrid1_EnterCell
    End Sub
    
    Private Sub MSHFlexGrid1_KeyDown(KeyCode As Integer, Shift As Integer)
    MSHFlexGrid1_EnterCell
    End Sub
    
    Private Sub MSHFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    MSHFlexGrid1_EnterCell
    End Sub
    Last edited by Stupidiot; Jun 17th, 2011 at 03:21 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
  •  



Click Here to Expand Forum to Full Width