Jump to content

dbgrid color problem


allenchow

Recommended Posts

1. When I use DrawColumnCell to change a row color for particular condition, the default color for selection won't show anymore for those rows when selecting. (It won't like that before using ver 6 js)

 

2. How to change all grid border color to black for all dbgrid without using theme ?

 

Thanks!

Link to comment
Share on other sites

Your column width is not the same as mine. Just keep the original width

 

 

Also, I've mentioned before that there are spaces below each rows inside dbgrid

I've attached the test case

Thanks !

 

I did not change anything

Link to comment
Share on other sites

I've found a very weird thing : 

Just unzip to a folder and open the project, (DONT'S OPEN the MAIN.PAS FILE) , compile and run !

You will see the difference. 

Once you open the main.pas file, it will be normal again ..........

Don't know why !

Link to comment
Share on other sites

Also when you open main.dfm with notepad, you'll see the column of company is 64 :

       item
          FieldName = 'Company'
          Title.Caption = 'Company'
          Width = 64
        end
        item
 
But when open inside Delphi , it changes to 184 automatically 
Link to comment
Share on other sites

 

Also when you open main.dfm with notepad, you'll see the column of company is 64 :

       item
          FieldName = 'Company'
          Title.Caption = 'Company'
          Width = 64
        end
        item
 
But when open inside Delphi , it changes to 184 automatically 

 

 

TColumn has a method named DefaultWidth (64), which is called in particular when the width hasn't been explicitly assigned to the column (which is true for the dynamically created grid columns).

Basically, it takes the column's associated field's display width (in chars) and multiplies it by the width of the 0 character (in pixels), using the corresponding font.

It then compares the result to the width of the title (in pixels) and returns the greater value.

 

https://stackoverflow.com/questions/5446520/how-does-a-dbgrid-component-determine-initial-column-widths-to-display

Link to comment
Share on other sites

 

TColumn has a method named DefaultWidth (64), which is called in particular when the width hasn't been explicitly assigned to the column (which is true for the dynamically created grid columns).

Basically, it takes the column's associated field's display width (in chars) and multiplies it by the width of the 0 character (in pixels), using the corresponding font.

It then compares the result to the width of the title (in pixels) and returns the greater value.

 

https://stackoverflow.com/questions/5446520/how-does-a-dbgrid-component-determine-initial-column-widths-to-display

 

Thanks, in that case, I can't set width 64 ! Otherwise it will change to other width. 

I change to width 65 now . Try project 1 above

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...