问题
I have bumped into a pretty confusing problem.
At design time, I clearly indicate the size of columns (width and Max width) for the TDBGrid.
Here's the problem...

Please ignore the rest of the screen. My only concern is the window with the grid :)
Is there any way I can fix this?
BTW, I'm working on Ubuntu with Lazarus but the software may be on Ubuntu or Windows.
I'd really appreciate nay inputs on this. Thanks!
回答1:
I'm not sure if this is the right answer but a simliar question was posted elsewhere about DELPHI here: How do I make a TDBGrid's columns fit the grid's width?
And I used the answer of J.Pelttari here: https://stackoverflow.com/a/2004473/560161
I simply added 1 to each column's width and it looks good.
Here's the code:
for x:=0 to dgFlockCodeSearch.Columns.Count-1 Do
begin
dgFlockCodeSearch.Columns[x].Width:=dgFlockCodeSearch.Columns[x].Width +1;
end;
来源:https://stackoverflow.com/questions/18798169/why-does-the-tdbgrid-take-up-more-space-at-run-time