MSFlexGrid: All rows are highlighted when fixed column 0 in fixed row 0 is clicked

I am populating a flexgrid with data. The dimensions of the grid very as the data varies.  That being said, I have one fixed column (0) and one fixed row (0) in the flexgrid.  The fixed row is used as a header row and to allow the user to indicate which column they want to sort data.  I have one fixed column that is used to display an image that matches to data it's associated row.  I do not want the image to highlight when the row is selected so that's why I made it a fixed column.  My issue is that when the user clicks on row 0 and column 0 all rows in the grid appear highlighted.  Does anyone know why this happens and what the solution is to resolve the problem?

Thanks for your help
Jim Von Dolteren
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


MSFlexGrid is a special control which is originally designed in visual basic. If you are clicking on any area other than the cells displayed area then automatically it will be treated as row 0 and column 0 clicked. If you are clicking on row 0 and column 0 then automatically it will be treated as all rows and columns clicked. To avoid it write a click event for the MSFlexGrid control and in that put a condition if the clicked row or column should not be zero like the following.

If result.rowsel <> 0 Then
end if

You can try the next code...

Private Sub GRILLA_Click()
    With GRILLA
        If (.RowSel = .Rows - 1) Then
            .Row = 0
            .Col = 0
        End If
    End With
End Sub

Open in new window

jfvonAuthor Commented:
I think I haven't stated the problem correctly.  I need to be able to tell which column has been clicked in header row. The header row (row 0)  is fixed. The first column (column 0) is also fixed.  Unfortunately, when the user clicks on row 0, column 0 all the rows in the grid are momentarily highlighted.  I would like to prevent this from occurring. If as srinivasbn states that there is a by product of the control itself then I'll look in a different direction.
ok, then you have to change the behavior of the grid when a fixed col or row is cliked... you have to simulate the selection of the range of cells.

try the next code...


Ing. Fernando D. Giletta
MP: 4035 CIEC
San Fco. Cba. Arg.

Private Sub Form_Load()
    With grilla
        .Rows = 10
        .Cols = 5
        .AllowBigSelection = False
    End With
End Sub
Private Sub grilla_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    With grilla
        If (.MouseRow = 0) And (.MouseCol > 0) Then
            .Col = .MouseCol
            .RowSel = .Rows - 1
            Exit Sub
        End If
        If (.MouseCol = 0) And (.MouseRow > 0) Then
            .Row = .MouseRow
            .ColSel = .Cols - 1
            Exit Sub
        End If
    End With
End Sub

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.