For JustinB

Posted on 1999-07-12
Medium Priority
Last Modified: 2010-05-02
In regards to Q.10180473.  Would give you more points for it, but I've already implemented Sheridan grids in place of the flexgrids, that and I'm low on points.  Curiousity got the better of me.
Question by:BeedleGuis

Accepted Solution

JustinB earned 80 total points
ID: 1524078
Yeah..I would have liked more points for it but this really made the Microsoft flex grid a far more attractive option to Sheridan. Given the distribution hassles I have had with sheridan the flex grid is better I think even though it does
not have as many features and does not really look as good.

Anyway here is the code:

Private Sub bgrdSearch_Click()
Dim pntGridPoint As POINTAPI
Dim pntClickPoint As POINTAPI
    If bgrdSearch.Rows > 1 Then
        pntGridPoint.x = 0
        pntGridPoint.y = 0
        GetCursorPos pntClickPoint
        ClientToScreen bgrdSearch.hWnd, pntGridPoint
        ' Determine if the user clicked on the fixed row
        If (pntClickPoint.y >= pntGridPoint.y) And (pntClickPoint.y <= pntGridPoint.y + 15) Then
            ' If the user has clicked on a column heading then sort
            ' the grid by that column
            prHeadClickSort pntClickPoint.x, pntGridPoint.x
            ' Allow selection of multiple rows if required
            If bMultiSelect Then
                If bgrdSearch.TextMatrix(bgrdSearch.Row, 0) <> "*" Then
                    bgrdSearch.TextMatrix(bgrdSearch.Row, 0) = "*"
                    nNumSelections = nNumSelections + 1
                    bgrdSearch.TextMatrix(bgrdSearch.Row,0) = ""
                    nNumSelections = nNumSelections - 1
                End If
            End If
        End If
    End If
End Sub

        POINTAPI is a type
        GetCursorPos and ClientToScreen are API calls

You can get info on these from the API text viewer that comes with VB

The scale mode of the form that the grid is on is important.

This code determines if the user has clicked anywhere
on the title part of the grid. You can then use the x value and the column widths to determine which of the actual columns the user clicked on. I have not included this code
as I have added substantially to it and it was a bit of a mess. This should give you all you need to know to do it anyway and for 20 points I do not think it is a bad deal.

Hope it helps.


Author Comment

ID: 1524079
Thanks JustinB, I probably won't use it though, I was just curious as to how it could be done.  I too thought about determining cursor postion on the click event if the row prop was 1, but decided it would be to much of a hassel.  Thanks for satisfing my curiousity . .

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

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

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…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
Suggested Courses

601 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