Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > DB-Aware

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 04-05-2003, 08:59 PM
emayjpatts emayjpatts is offline
Member
 
Join Date: Jul 2001
Posts: 64
Default simple ? in DbGrid

How can i create dbgrid field during run-time? Although it can be done during design time but i prefer to do it during run-tim, can anyone help?

Thank you

'Trust in the LORD with all your heart and Lean not with your own understanding, in all your ways acknowledge Him and He shall direct thy PATH'

emayjpatts
Reply With Quote
  #2  
Old 04-05-2003, 10:24 PM
Sylvestre Sylvestre is offline
Senior Member
 
Join Date: Mar 2003
Posts: 116
Default RE: simple ? in DbGrid

You can do it like that :

for I := 0 to NumberOfColumn - 1 do
begin
Grid.Columns.Add();
Grid.Columns[I].FieldName := YourField;
Grid.Columns[I].Width := YourSize;
Grid.Columns[I].Title.Caption := YourCaption;
Grid.Columns[I].Title.Alignment := YourAlignment;
end;


Sylvestre
Reply With Quote
  #3  
Old 04-05-2003, 10:32 PM
tpt tpt is offline
Member
 
Join Date: Feb 2003
Posts: 82
Default RE: simple ? in DbGrid

Hi.

Try this.

procedure AddColumn(AFiled:TField;ADisplayCaption:String);
var DBGColumn:TColumn;//the new column
begin
DBGColumn:=DBGrid1.Columns.Add; //create new column in DBGrid
DBGColumn.Field:=AField{--> Field You wont assign to column };
DBGColumn.Title.Caption:=ADisplayCaption;

end;

Hope it Helps
Reply With Quote
  #4  
Old 04-05-2003, 10:49 PM
emayjpatts emayjpatts is offline
Member
 
Join Date: Jul 2001
Posts: 64
Default : simple ? in DbGrid

both of you answered it correctly, thank you guys

'Trust in the LORD with all your heart and Lean not with your own understanding, in all your ways acknowledge Him and He shall direct thy PATH'

emayjpatts
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:55 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.