Solved

MSFlexGrid

Posted on 2000-03-17
2
521 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Best way to parse out a json string in VB6? 10 395
Access Object Property from VBA Module in Excel 2010 2 45
backup program with robocopy 6 91
Modify Text File with Excel Macro 13 50
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

751 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