• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 231
  • Last Modified:

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
0
jfvon
Asked:
jfvon
  • 2
1 Solution
 
srinivasbnCommented:
Hi

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
0
 
FER_GCommented:

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

0
 
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.
0
 
FER_GCommented:
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.

so...
try the next code...

Regards,
FerG

Saludos
--
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

0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now