Solved

MSFlexGrid

Posted on 2000-03-17
2
516 Views
Last Modified: 2008-02-26
How can we make MSFlexGrid as spreedsheet, so that we can select multiple cells by draging them? For example, if I drag from cell1 to cell5, the cells should get the different background. When I drag someother area, the previously selected area should be retained.

I have made the property "High Light" as 0(Never), dragmode as automatic and I take care of changing the background color in "DragOver" event. My requirement is fulfilled, but the control is shaking and the entire control gets draged(moved) as the mouse moves. I want to avoid that.

My code is:


Private Sub msxTimeRestriction_Click()
    With msxTimeRestriction
        If .Col = 0 Then Exit Sub
        If .CellBackColor = &H80000005 Then  'white
            .CellBackColor = &H8000&    'Green
        Else
            .CellBackColor = &H80000005
        End If
    End With
End Sub

Private Sub msxTimeRestriction_DragOver(Source As Control, x As Single, y As Single, State As Integer)
    Dim intRow As Integer
    Dim intCol As Integer
    Dim intFixColWidth As Integer
    Dim intColWidth As Integer
    Dim intCellHeight As Integer
   
   
    With msxTimeRestriction
        intFixColWidth = .ColWidth(0)
        intColWidth = .ColWidth(1)
        intCellHeight = .CellHeight

        If x <= intFixColWidth Then
            strDayTime = "Time Restrictions"
        Else
            'Set the row and column appropriately
            intRow = Int(y / intCellHeight)
            If intRow > 6 Then
                intRow = 6
            ElseIf intRow < 0 Then
                intRow = 0
            End If
            .Row = intRow

            intCol = Int((x - intFixColWidth) / intColWidth)
            If intCol > 23 Then
                intCol = 23
            ElseIf intCol < 0 Then
                intCol = 0
            End If
            .Col = intCol + 1
           
        If .CellBackColor = &H80000005 Then  'white
            .CellBackColor = &H8000&    'Green
        Else
            .CellBackColor = &H80000005
        End If

        End If


    End With

End Sub
0
Comment
Question by:jayaraghu
2 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 100 total points
ID: 2629618
I don't understand, because the normal operation of the MSFlexGrid is to select cells normally without any coding.

Are you trying to do something different then select cells?
0
 

Author Comment

by:jayaraghu
ID: 2635012
My requirement is:

Changing the background color of the cells which I select thru mouse. The selection will be multiple cells at random place. Currently, with MSFlexGrid, I can select multiple cells, at that time,the selected cells got focused. Then, if I go for selection in some other group of cells, the focus is moved to the new place, and the background change of my previous selection got lost. I want to overcome this. Please help me.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question