Click to See Complete Forum and Search --> : How to send messages to Grid Control


giriaiyer
September 13th, 1999, 11:09 AM
Hi,
I want to send messages to MSFlexGrid using SendMessage API. What is the Constant do i need to use in wParam Parameter. Any help is much appreciated. Tx in advance
Giri

Lothar Haensler
September 14th, 1999, 01:20 AM
the values for wParam and lParam are message specific, i.e. depending on the message you want to send, you'll have to spend different parameters.
So tell us what message you want to send.

giriaiyer
September 14th, 1999, 08:28 AM
I want to find particular value say a string "abc" in the cell 1,1(Is there any msg like LB_FINDSTRING!)

Chris Eastwood
September 14th, 1999, 08:56 AM
Rather than relying on a message/api solution and I couldn't find anything on messages for the FlexGrid in the VC++ headers), couldn't you just use a routine similar to the one below ? :


private Function FindInGrid(byval sText as string, _
optional lColumn as Long = -99)
'
Dim lRowCount as Long
Dim lRows as Long
Dim lColCount as Long
Dim lStartRow as Long
'
If lColumn < 0 then
lColumn = 0
End If
'
With MSFlexGrid1
.Redraw = false
lRows = .Rows - 1
lStartRow = .FixedRows
'
for lRowCount = lStartRow to lRows
'
If InStr(1, .TextMatrix(lRowCount, _
lColumn), sText, vbTextCompare) then
'
FindInGrid = lRowCount
.Redraw = true
Exit Function
End If
'
next
.Redraw = false
End With
'
FindInGrid = -1 ' not found
'
End Function




This routine will return the row number of the row where the text was found for the specified column.

I ran this code on 1000 rows in a flexgrid and it found a match in under 0.5 seconds.



Chris Eastwood

CodeGuru - the website for developers
http://codeguru.developer.com/vb