tdbgrid

How to auto fit/scale DBGrid's (or other similar) columns widths according to its contents?

送分小仙女□ 提交于 2019-11-30 19:35:51
I am trying to make a frame with a DBGrid that will serve for more than 10 tables with half of its fields as defaults, and other fields exclusive for each table. As the space for the columns are limited and I do not want to configure each column of each table manually because it is very poor quality work, I was wondering a way to calculate the width of each column by the largest content of a row inside that column, measured by the own component or by the data set. Does anyone knows the way? Is there out in the world some custom component with that power? I need a solution that implements

how to keep track of selected rows with dgRowSelect = False

…衆ロ難τιáo~ 提交于 2019-11-29 12:57:01
When dgRowSelect = False how can i detect the selected row within the OnDrawColumnCell method? Not the selected cell, but the row that contains the selected cell. The code below seems to work. The TDBGrid still keeps SelectedRows updated (even though it doesn't draw with them without dgRowSelect enabled), so you can still access them in your drawing code. (You do still need to enable dgMultiSelect , even though dgRowSelect is not needed.) The code lets the grid do all of the drawing, just setting the Canvas.Brush.Color on the selected rows. The supplied color will be overridden by the drawing