| Delphi .NET (2) Database (71) Delphi IDE (90) Network (39) Printing (3) Strings (12) VCL (83) Windows with Delphi (280)
New related comments Number of comments in the last 48 hours Access the current row/column of a TMemo |
A listbox in a cell of a stringgrid
(1 votes). Leave comments and/ or rate it.
Here's another great trick by programmer illusionists. What appears as embedded comboboxes within a stringgrid is actually just a combobox floating above the stringgrid, and it just so happens to be the exact same size as the stringgrid cell underneath it. Here's the basics:
In essence, the main routine here is the stringgrid's OnDrawCell event handler. Of course, I also set the stringgrid's DefaultRowHeight property to be the same height as the combobox. In addition, the stringgrid's OnTopLeftChanged event handler is used to hide the combobox when the user scrolls out of view. Also, when the user selects an item from the combobox, simply place the text in the current Col/Row.
You can also do a couple other little tricks such as setting the
stringgrid's Objects[] property to point to the combobox, as well as
possibly setting the combobox's Parent property to point to the stringgrid.
However, I've had problems with the Parent approach -- namely, that of
dropping down the listbox associated with the combobox.
Comments:
|