Board index » delphi » String Grid question

String Grid question

Hello!

I have a String Grid with 2 columns filled with data.
1-st field = customer name, 2-nd number of ordered items.
How to check which customer and which row the user means
clicking on the cell with the number of ordered items?
Or how to identify the selected row at all?

Thanks

Tom

 

Re:String Grid question


Quote
In article <8m24s9$5...@bornews.borland.com>, Tom wrote:
> Or how to identify the selected row at all?

See the Row and Col properties.

 Mike Orriss (TeamB & Developer Express)
 (Unless stated otherwise, my replies relate to Delphi 5)
 (No unsolicited e-mail replies please)

Re:String Grid question


Quote
In article <8m24s9$5...@bornews.borland.com>, Tom wrote:
> I have a String Grid with 2 columns filled with data.
> 1-st field = customer name, 2-nd number of ordered items.
> How to check which customer and which row the user means
> clicking on the cell with the number of ordered items?
> Or how to identify the selected row at all?

Tom,

if you use the grids onClick event the grids Col and Row properties will
refer to the cell the user clicked on, since a click selects the cell
(unless you have an OnSelectCell handler that refuses to select the cell).

An alternate strategy is to use the grids MouseToCell method to figure out
the cell coordinates from mouse position. This is useful in a handler for
OnMousedown or OnMouseup, for example. In OnClick you would have to get the
cursor position using Mouse.CursorPos and convert it to grid-relative
coordiantes first using the grids ScreenToClient method.

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Other Threads