0

I am new to Delphi Firemonkey using Embarcadero® RAD Studio 10 Seattle. I create at runtime a Tgrid. How can i give name to column and fill data in row ? My code is below.

procedure TForm1.Button1Click(Sender: TObject);
var
  Grid : TGrid;
begin
  Grid := TGrid.Create(Form1);
  Grid.Visible := True;
  Grid.Parent := Form1;
  Grid.Align := Grid.Align.alClient;
  Grid.RowCount := 5;
end;
Tom Brunberg
  • 20,312
  • 8
  • 37
  • 54
  • Please, only tag your questions with the general `delphi` tag and the tag for your actual version `delphi-10-seattle` in your case now and `firemonkey` to indicate the library you use. If your target platform is important for understanding of your question, you could also tag accordingly. – Tom Brunberg May 26 '20 at 13:43
  • You have provided the exact same code as in your previous question, huh? Sure you should at least include also the column creating code, no? And finally what did you try with? What exactly do you mean with "name" for the column? Name as the `Name` property of all objects or "Name" as header text? Please pay attention to explain with a little more detail. – Tom Brunberg May 26 '20 at 13:50
  • @TomBrunberg i mistaken Column name means heading of column Like Address, City. I googled but i m not getting how to give heading to column and fill data in cells by creating rows (data will be form query). – Dharmesh Bhagatwala May 26 '20 at 15:38
  • @TomBrunberg There are 3 forms (Sales, Purchase, Items) in app and i want to show their data in respected format using grid. So i want to make one procedure with required parameter that can create grid at run time and can give heading to column and fill data in cells. So Wherever i want to display my data in grid format i can call this procedure with respected parameter and all data will be available in proper format. if u have any doubt please ask. i want to solve it if u can help. – Dharmesh Bhagatwala May 26 '20 at 15:38
  • @MartynA thanks for that reply. Its visible now but how to add data in it ? – Dharmesh Bhagatwala May 26 '20 at 15:44
  • If you are asking how to populate a TGrid with data at design time, use the right-click pop-up menu to add columns to it and then use the Live Bindings Wizard from the same menu to add the data. – MartynA May 26 '20 at 16:59

1 Answers1

1

If by name you mean the heading that is visible at the top of the column, then:

Each column (which you also have to create) is a TColumn of some kind (for example a TStringColumn). TColumn has a Header property (a string), that you can set, that specifies the string in the header cell of the column.

See http://docwiki.embarcadero.com/Libraries/Seattle/en/FMX.Grid.TColumn.Header

Matthias B
  • 404
  • 4
  • 11