Why does the TDBGrid take up more space at run-time?

China☆狼群 提交于 2019-12-11 05:05:24

问题


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...

As you see, the design time and run-time grids are different in size. And also note that the form is the same size.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!