QuickStart
Crie um aplicativo VCL, solte um TsgcVCLGrid da página SGC Grid da paleta no form, dê um clique duplo no form para obter o FormCreate e digite as linhas abaixo. Pressione F9. O mesmo grid no C++Builder e em um aplicativo .NET WinForms está nas outras abas.
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 recebe os valores na ordem das colunas. UpdateRow recebe nomes de campos, então uma mensagem que traz apenas um preço altera somente o preço, e uma chave que ainda não existe é inserida. As colunas também podem ser adicionadas em design-time com o editor Columns, e um TsgcGridSource_DataSet da mesma página da paleta preenche o grid a partir de qualquer 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))));
}
O C++Builder usa os mesmos componentes por meio dos headers e das bibliotecas que o instalador do C++Builder gera. Os open arrays do Delphi são passados com a macro OPENARRAY. Ou dispense o código, solte o TsgcVCLGrid no form e defina as colunas no 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);
}
}
Os nomes das classes seguem os do Delphi: TsgcWinFormsGrid para WinForms, TsgcWpfGrid para WPF, com os mesmos membros Columns e Data em cada um. Os pacotes WinForms têm como alvo o .NET Framework 4.7.2 e o .NET 8, 9 e 10 para Windows.