OK, so we accept that you want to create a generic device with an arbitrary number of columns, and therefore an arbitrary number of selection criteria. That in itself is not difficult. What's giving us problems is the fact that you want the selection criteria boxes to always appear above the corresponding grid columns, even when the user horizontally scrolls the grid or resizes the columns (or, presumably, when they re-arrange the order of the columns, assuming you allow that).
If you could relax that requirement, the whole thing would be considerably easier.
The way I would do it is to use textboxes for the selection criteria, but to arrange them in a vertical block, one beneath the other, to the right of the grid. I would create a class that contains the grid, with a blank space for where the textboxes will appear. At its simplest, the Init event of the class would look at the number of columns in the grid (or, perhaps, the number of fields in the underlying cursor), and instantiate that number of textboxes, one beneath the other.
In fact, I'd go one step further. I would not assume that every field in the cursor would be eligible as a selection criterion. I would identify the key fields that the user is likely to want to select on, and provide a property of the class that tells it which those fields are. It would be up to the developer to specify a value for that property at design time.
It would also be up to the developer to ensure that, when placing the class on the form, there is enough space to show the required number of textboxes.
I know this won't look quite as slick as the original plan - that is, making it look like the user is entering the criteria directly into the grid - but it would be considerably easier to implement.
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
Visual FoxPro articles, tips and downloads