Jump to content
tgbs

Problem with column names in dbgrid

Recommended Posts

If there is an invisible column, the name of the next column that is not fully visible is not drawn

 

screenshot_7.png.b0c1047c383083f7bcf39e8649e45c15.png

If Second column is visible = false then

screenshot_6.png.63876e7372145787013694eb680ab4aa.png

This can be seen in the design time as well
Delphi Alexandria with the update

Edited by tgbs

Share this post


Link to post

You forgot one piece of information. What a component it is.

Share this post


Link to post

TDBgrid. Problem is in Vcl.Grids

Share this post


Link to post

TDBGrid is doing a really crappy job in sizing it's columns and however I didn't meet the issue you describe, I simply consider it to this "feature".

 

Have a look at this snipplet for a possible fix; I started mine based on this too.

Share this post


Link to post

I wanted to do this for a really long time so I started to extract the core improvements of Delphi's TDBGrid into a separate component. This includes:

- New public BeginUpdate / EndUpdate methods, which can disconnect the dataset and keep the previous image on the component. This is useful if you are doing opens / posts / anything in a background thread but don't want to show emptiness until

- Automatic and manual fitting of columns which considers the column and the content width but won't let a column be wider than half it's size

- Vertical scrollbar now works properly, not only 3 positions and is not visible when not needed

- Grid properly handles mouse wheel scrolling

- Content is shown as the scrollbar is dragged (not only updating when the mouse is released)

- If there is no connected dataset or it is not active, the two empty cells won't be shown

- Every second row has a slightly different background, out-of-focus selection is now drawn with a separate shade of grey, so you can see that the grid is not in focus. This considers VCL styles.

- If TitleClick or TitleHotTrack is enabled, the cursor changes to a hand instead of the pointers

 

It might get more updates later on when I see what code can be generally used from my heavily customized one.

 

Feel free to grab it / check how things were done. Tried to put comments everywhere.

Edited by aehimself
  • Like 2

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×