Jump to content


Photo

Right-most column shrunk in second loop onward


  • Please log in to reply
2 replies to this topic

#1 littlebigfred

littlebigfred
  • Members
  • 176 posts

Posted 24 August 2009 - 08:50 PM

Hello

I'm having a problem setting the right-most column to use all the remaing space.

It's a basic point-of-sale program. I run a loop to let the user type an article ID in an InputBox, I look up this article in the database, add a row in the NextGrid for this new article, and go back for another loop until the user clicks on Cancel.

After the very first iteration, the right-most column looks right, but it's shrinked after that:

http://img513.images...grightcolum.jpg

Here's the code:

http://pastebin.ca/1541767

Is it a bug, or maybe I'm not setting the grid's properties at the right location?

Thank you.

#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 25 August 2009 - 01:07 AM

Hello Fred,

I am not sure that I am correct, but maybe calling BestFitColumn on last column made a problem.

Try also, when you finish with adding columns to call:

CODE
  NextGrid1.Columns.ResizeColumns();


Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 littlebigfred

littlebigfred
  • Members
  • 176 posts

Posted 07 September 2009 - 05:32 PM

Thanks, that solved the problem.

Here's some code to create columns at run-time, while allowing long headers to fit and also have the right-most column fill the available space on its right:

CODE
With NextGrid1 do begin
  Columns.Add(TNxTextColumn,'Loooooooooooooooooooooong Col');
  Columns[0].Name := 'Col0';

  Columns.Add(TNxTextColumn,'Col1');
  Columns[1].Name := 'Col1';

  //Required for correct sorting of string columns that contain numeric contents
  ColumnByName['Col0'].SortType := stNumeric;

  for index := 0 to Columns.Count - 1 do begin
    BestFitColumn(index, bfBoth);
    Columns[Columns.Count - 1].Options := Columns[Columns.Count - 1].Options + [coAutoSize];
  end;
  Columns.ResizeColumns();
end;





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users