Solved

MSFlexGrid

Posted on 2000-03-17
2
510 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now