Solved

MSFlexGrid

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

862 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

23 Experts available now in Live!

Get 1:1 Help Now