Jump to content


Photo

AddCells method for NextGrid


  • Please log in to reply
3 replies to this topic

#1 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 10 May 2005 - 04:14 PM

Hi,

I have add new method (will be ready for 3.2) in NextGrid ideal for small grids and testings:

CODE
procedure AddCells(ACells: array of WideString);


Example how to use it:

1) Create new NextGrid and add 2 columns
2) Place one Button and add next code for OnClick:
CODE
NextGrid1.AddCells(['one', 'two', 'three', 'four', 'five', 'six']);

3) Run program and click on button.

You will see that this method automaticaly create rows and add next element of array into next cell.

This method will be available in v3.2. If you have some comments about this feature, or you have idea how to improve it, we can talk here.

If someone like to use it in current version, here is a code:
CODE
procedure TNextGrid.AddCells(ACells: array of WideString);

var

 I, Col: Integer;

begin

 AddRow;

 I := 0;

 while I < Length(ACells) do

 begin

   for Col := 0 to Columns.Count - 1 do

   begin

     Cells[Col, RowCount - 1] := ACells[I];

     Inc(I);

   end;

   if I < Length(ACells) then AddRow;

 end;

end;


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.

#2 wvd_vegt

wvd_vegt

    Master Member

  • Honorable Members
  • PipPipPipPipPip
  • 710 posts
  • Gender:Male
  • Location:the Netherlands

Posted 10 May 2005 - 10:30 PM

Hi Boki

Handy function with only two limitation that is that you need to know the order of the columns and can't have any gaps when filling.

I'm also not sure in which order they are after I drag columns around. Do they change when dragging?

Perhaps you can also have a look at an old snippet I posted as AddRowWithValues. It allowed you to specify a list of column names and their content as a variant array.

http://forum.bergsof...wtopic.php?t=95

A bit similair in design where the Locate and Lookup functions I posted that mimic the DB versions.
G.W. van der Vegt

#3 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 10 May 2005 - 10:43 PM

Hi Wim,

It is allways filled with using Index , not Position. Maybe I can use Flag coPublicUsing in Column.Options, to determine which column will "grab" value.

Also, maybe I can use next solution (if is possible):

CODE
procedure AddCells(ACells: array of WideString; AffectedColumns: array of WideString);


but, I will like to made AColumns array to be optional. Do you maybe know have to made Array parameter to be optional?

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.

#4 wvd_vegt

wvd_vegt

    Master Member

  • Honorable Members
  • PipPipPipPipPip
  • 710 posts
  • Gender:Male
  • Location:the Netherlands

Posted 11 May 2005 - 09:46 AM

Hi Boki,

Without compiler at hand my guess would be adding

CODE
AffectedColumns: array of WideString = [];


and test for it's zero length. To really make it optionally you have to overload the function.
G.W. van der Vegt




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users