QuickStart
Create a VCL application, drop a TsgcVCLGrid from the SGC Grid palette page on the form, double click the form to get FormCreate and type the lines below. Press F9. The same grid in C++Builder and in a .NET WinForms application is on the other tabs.
uses
SysUtils, Classes, Controls, Forms,
sgcGrid_Columns, sgcGrid_Data, sgcGrid_VCL;
type
TForm1 = class(TForm)
sgcVCLGrid1: TsgcVCLGrid;
procedure FormCreate(Sender: TObject);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
sgcVCLGrid1.Align := alClient;
sgcVCLGrid1.Columns.Add('Symbol', 'Symbol');
sgcVCLGrid1.Columns.Add('Price', 'Price', gdtFloat).DisplayFormat := '0.00';
sgcVCLGrid1.Columns.Add('Volume', 'Volume', gdtInteger);
sgcVCLGrid1.Data.AppendRow('MSFT', ['MSFT', 412.5, 1200]);
sgcVCLGrid1.Data.AppendRow('AAPL', ['AAPL', 228.1, 3400]);
sgcVCLGrid1.Data.UpdateRow('MSFT', ['Price', 'Volume'], [413.1, 1350]);
end;
AppendRow takes the values in column order. UpdateRow takes field names, so a message that only carries a price only touches the price, and a key that does not exist yet is inserted. The columns can also be added at design time with the Columns editor, and a TsgcGridSource_DataSet from the same palette page fills the grid from any TDataSet.
#include <vcl.h>
#include "sgcGrid_Columns.hpp"
#include "sgcGrid_Data.hpp"
#include "sgcGrid_VCL.hpp"
void __fastcall CreateGrid(TForm *Form)
{
TsgcVCLGrid *Grid = new TsgcVCLGrid(Form);
Grid->Parent = Form;
Grid->Align = alClient;
Grid->Columns->Add("Symbol", "Symbol", gdtText);
Grid->Columns->Add("Price", "Price", gdtFloat)->DisplayFormat = "0.00";
Grid->Columns->Add("Volume", "Volume", gdtInteger);
Grid->Data->AppendRow("MSFT", OPENARRAY(Variant,
(Variant("MSFT"), Variant(412.5), Variant(1200))));
Grid->Data->AppendRow("AAPL", OPENARRAY(Variant,
(Variant("AAPL"), Variant(228.1), Variant(3400))));
}
C++Builder uses the same components through the headers and libraries the C++Builder installer builds. Delphi open arrays are passed with the OPENARRAY macro. Or skip the code, drop the TsgcVCLGrid on the form and set the columns in the Object Inspector.
using System;
using System.Windows.Forms;
using esegece.sgcGrid;
internal static class Program
{
[STAThread]
private static void Main()
{
Application.EnableVisualStyles();
Form oForm = new Form { Text = "My first sgcUI form", Width = 640, Height = 360 };
TsgcWinFormsGrid oGrid = new TsgcWinFormsGrid { Dock = DockStyle.Fill };
oGrid.Columns.Add("symbol", "Symbol");
oGrid.Columns.Add("price", "Price", TsgcGridDataType.gdtFloat).DisplayFormat = "0.00";
oGrid.Columns.Add("volume", "Volume", TsgcGridDataType.gdtInteger);
oGrid.Data.AppendRow("MSFT", "MSFT", 412.5, 1200);
oGrid.Data.AppendRow("AAPL", "AAPL", 228.1, 3400);
oGrid.Data.UpdateRow("MSFT", new[] { "price", "volume" }, new object[] { 413.1, 1350 });
oForm.Controls.Add(oGrid);
Application.Run(oForm);
}
}
The class names follow the Delphi ones: TsgcWinFormsGrid for WinForms, TsgcWpfGrid for WPF, and the same Columns and Data members on each. The WinForms packages target .NET Framework 4.7.2 and .NET 8, 9 and 10 for Windows.