Solved

MSFlexGrid

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

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month10 days, 1 hour left to enroll

623 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