Recent

Author Topic: DBGrid - How to resize columns at design time  (Read 14282 times)

atasoft

  • New Member
  • *
  • Posts: 33
DBGrid - How to resize columns at design time
« on: June 30, 2011, 09:33:17 pm »
I am new in Lazarus and I am developing my first database project. I am using DBGrid in my form and I found out that I am not able to resize its columns at design time using the mouse. It takes time to resize the columns using the Width property. Using the mouse in Delphi I can resize the columns of DBgrid.

Am I doing something wrong?

cpalx

  • Hero Member
  • *****
  • Posts: 753
Re: DBGrid - How to resize columns at design time
« Reply #1 on: July 01, 2011, 04:54:30 am »
Did you try
dbgrid.ColumWidth[ iColPosicion ] := 250 (* For example *) ;

atasoft

  • New Member
  • *
  • Posts: 33
Re: DBGrid - How to resize columns at design time
« Reply #2 on: July 01, 2011, 04:39:37 pm »
Quote
Did you try
dbgrid.ColumWidth[ iColPosicion ] := 250 (* For example *) ;

Using your code I can change the width of a column at runtime. The working code should be like this: dbgrid.Columns.Items[iColPosition ].Width := 250;

But anyway my problem is not how to change the column width in runtime but at design time using mouse.

Maybe it is bug or better, weakness of lazarus.

JanRoza

  • Hero Member
  • *****
  • Posts: 672
    • http://www.silentwings.nl
Re: DBGrid - How to resize columns at design time
« Reply #3 on: July 01, 2011, 05:04:52 pm »
To change the column width at design time click on the grid, in the properties select the colums item and click on the little button behind it. Now you will see a little popup window which shows you all the columns. Select a column and in the properties of that column change the Width property. You can do this for every column until you're satisfied.
OS: Windows 10 (64 bit) / Linux Mint (64 bit)
       Lazarus 3.2 FPC 3.2.2
       CodeTyphon 8.40 FPC 3.3.1

atasoft

  • New Member
  • *
  • Posts: 33
Re: DBGrid - How to resize columns at design time
« Reply #4 on: July 01, 2011, 07:00:49 pm »
Quote
Select a column and in the properties of that column change the Width property.

Thanks but I know this way. The problem it takes me time to resize the width with this way, especially If I  need to resize the width according to the width of its title. In Delphi I can easily resize the width of the dbgrid column at design time using the mouse !!!

JanRoza

  • Hero Member
  • *****
  • Posts: 672
    • http://www.silentwings.nl
Re: DBGrid - How to resize columns at design time
« Reply #5 on: July 01, 2011, 07:40:02 pm »
Sorry, I missed your mouse bit.
No need to shout however.
I think Lazarus does not have that possibility, at least -like you- I'm unable to find it.
OS: Windows 10 (64 bit) / Linux Mint (64 bit)
       Lazarus 3.2 FPC 3.2.2
       CodeTyphon 8.40 FPC 3.3.1

atasoft

  • New Member
  • *
  • Posts: 33
Re: DBGrid - How to resize columns at design time
« Reply #6 on: July 01, 2011, 09:43:12 pm »
Thanks, you are right this possibility is missing from lazarus.
Is it any third party dbgrid that has this possibility?

cpalx

  • Hero Member
  • *****
  • Posts: 753
Re: DBGrid - How to resize columns at design time
« Reply #7 on: July 02, 2011, 01:14:19 pm »
Did You try add items to the columns, dbgrid has Columns properties then you can add the columns you need. Then you can add the width column you need, i am not sure if with the mouse, ley me test.

atasoft

  • New Member
  • *
  • Posts: 33
Re: DBGrid - How to resize columns at design time
« Reply #8 on: July 03, 2011, 04:40:08 pm »
Quote
Did You try add items to the columns, dbgrid has Columns properties then you can add the columns you need. Then you can add the width column you need
Ok, but you can not use mouse to resize the column's width at design time like in Delphi.

Zoran

  • Hero Member
  • *****
  • Posts: 1831
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: DBGrid - How to resize columns at design time
« Reply #9 on: July 03, 2011, 09:22:50 pm »
Ok, but you can not use mouse to resize the column's width at design time like in Delphi.

You can make the feature request in bugtracker.

 

TinyPortal © 2005-2018