QuickStart
Bir VCL uygulaması oluşturun, SGC Grid palet sayfasından bir TsgcVCLGrid bileşenini forma bırakın, FormCreate olayını oluşturmak için forma çift tıklayın ve aşağıdaki satırları yazın. F9'a basın. C++Builder ve .NET WinForms uygulamasındaki aynı grid diğer sekmelerdedir.
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 değerleri sütun sırasıyla alır. UpdateRow alan adlarını alır, böylece yalnızca fiyat taşıyan bir mesaj sadece fiyata dokunur ve henüz var olmayan bir anahtar eklenir. Sütunlar tasarım zamanında Columns düzenleyicisiyle de eklenebilir ve aynı palet sayfasındaki bir TsgcGridSource_DataSet, gridi herhangi bir TDataSet üzerinden doldurur.
#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 aynı bileşenleri, C++Builder yükleyicisinin derlediği başlık dosyaları ve kitaplıklar üzerinden kullanır. Delphi açık dizileri OPENARRAY makrosuyla geçirilir. Ya da kodu atlayın, TsgcVCLGrid bileşenini forma bırakın ve sütunları Object Inspector'da ayarlayın.
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);
}
}
Sınıf adları Delphi'dekileri izler: WinForms için TsgcWinFormsGrid, WPF için TsgcWpfGrid ve her birinde aynı Columns ve Data üyeleri. WinForms paketleri .NET Framework 4.7.2 ile Windows için .NET 8, 9 ve 10'u hedefler.