Jump to content


Photo

Create a Column at Runtime


  • Please log in to reply
5 replies to this topic

#1 Pit

Pit
  • Members
  • 4 posts

Posted 14 February 2005 - 07:47 PM

1. Is there a way to do create a Column at runtime?
2. How can I set the Background Color of a Cell?

#2 MasterEvil

MasterEvil
  • Members
  • 104 posts
  • Location:Germany

Posted 14 February 2005 - 07:59 PM

hi there,

there are some articles about handling GridView on the Berg Site.

1.
GridView1.Columns.Add(TTextualColumn);
http://www.bergsoft....ridhowto#addcol

2.
GridView1.Cell[Col,Row].Color := clGreen;

#3 NoSi

NoSi
  • Members
  • 44 posts

Posted 14 February 2005 - 08:58 PM

QUOTE (MasterEvil)
hi there,

there are some articles about handling GridView on the Berg Site.

1.  
GridView1.Columns.Add(TTextualColumn);
http://www.bergsoft....ridhowto#addcol


I am trying this but always run into an EAccessViolation. I tried "Insert" as well, but this does not work, too.

I am using Version 2.9 - any ideas?

#4 NoSi

NoSi
  • Members
  • 44 posts

Posted 14 February 2005 - 09:04 PM

QUOTE (NoSi)
I am trying this but always run into an EAccessViolation. I tried "Insert" as well, but this does not work, too.


:oops: I "Destroyed" the columns to clear the whole grid and tried to add then. Seems to be the reason. Thought, this would be the fastest way... .

#5 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 14 February 2005 - 10:21 PM

Hi,

If you still have some problems, you can post specific code here for your problem smile.gif

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.

#6 NoSi

NoSi
  • Members
  • 44 posts

Posted 15 February 2005 - 10:51 AM

I solved my challenge but I am not shure, if I match best the oportunities, given with GridView:
I have to create different tables in a form, depending on the choice made in a pulldown. The columns do not corresponded anyway, so I have to
[list]
[*]delete the existing rows / columns
[*]create a new coloumn set
[*]fill the new contents
[*]optimize coloumn width
[list]

Here the code I use. It works fine, but maybe, there is a better solution. Because I am still trying to understand the several tools of "the suite", I am looking for "best match", to use the components most effective:

Note: "ergebnis" => GridView

"Clearing" the Grid:
CODE
for i := Ergebnis.Columns.Count - 1 DownTo 0 Do

 Ergebnis.Columns.Delete(i);


Creating one of the possible sets:

CODE
for i := 0 to 5 do

   Ergebnis.Columns.Add(TTextualColumn);



 for I := 6 to 7 do

 Begin

   Ergebnis.Columns.Add(TDateColumn);

   Ergebnis.Columns[i].Alignment := taCenter;

 End;

 

 FillGrid;  // Putting Data into the Grid


Rezising coloumns to best fit:

CODE
 for i := 0 to Ergebnis.Columns.Count - 1 do

 Begin

     Ergebnis.FitToLargest(Ergebnis.Columns[i]);

     // Make shure, that the columns are not to small for the sorting arrow:

     If Ergebnis.Columns[i].Width < 100 then Ergebnis.Columns[i].Width := 100;

 End;


All improvements welcome smile.gif




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users