Formula to calculate the Grid Column Width by GRID_WIDTH_AUTOSIZE

Moderator: Rathinagiri

Post Reply
User avatar
hmgchang
Posts: 273
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia

Formula to calculate the Grid Column Width by GRID_WIDTH_AUTOSIZE

Post by hmgchang »

Hola Masters,
I tried to use the GRID_WIDTH_AUTOSIZE and get the column width :

Image

DATA = WIDTH
A = 25
AB = 27
ABC = 36
ABCD = 45
ABCDE = 53
ABCDEF = 60
ABCDEFG = 69
ABCDEFGH = 78
ABCDEFGHI = 81
ABCDEFGHIJ = 87

Can i have the formular to calculate the width of the column in order to fit my data ?


Thks n Rgds
Chang
Attachments
grid width.JPG
grid width.JPG (77.24 KiB) Viewed 766 times
Just Hmg It !
User avatar
AUGE_OHR
Posts: 2064
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Formula to calculate the Grid Column Width by GRID_WIDTH_AUTOSIZE

Post by AUGE_OHR »

hi,

you need not to "calculate" as Listview can do it for you

you can "click" on line between Column to re-size Column

you can do it with this Code

Code: Select all

   hGrid := GetControlHandle( "Browse_1", "BLPRESS" )
   FOR i := 1 TO iMax
      //  LISTVIEW_SETCOLUMNWIDTH( hGrid, i - 1, -1 )  // LVSCW_AUTOSIZE
      LISTVIEW_SETCOLUMNWIDTH( hGrid, i - 1, - 2 )     // LVSCW_AUTOSIZE_USEHEADER
   NEXT
LVSCW_AUTOSIZE use longest Cell while LVSCW_AUTOSIZE_USEHEADER use Header Description to calculate optimal Size
have fun
Jimmy
Post Reply