Вывод таблицы

Пример вывода таблицы со своими данными в новом окне.
Можно раскрашивать ячейки с данными.

using TSLab.Script; using TSLab.Script.CanvasPane; using TSLab.Script.Handlers; namespace MyLib { public class TestDataGrid : IExternalScript { public void Execute(IContext ctx, ISecurity sec) { // Создаем новое окно "Мое окно" var window = ctx.AddWindow("MyWindow", "Мое окно"); // Рисуем таблицу 1 в окне "Мое окно" Variant1(window); // Рисуем таблицу 2 в окне "Мое окно" Variant2(window); } /// <summary> /// Первый вариант простая таблица с числами /// </summary> public void Variant1(IWindow window) { // Создаем таблицу var pane = window.CreateDataGridPane("MyTable1", "Моя таблица1", 0, "N0", "Номер", true, // включить номер индекса TextAlignment.Left, null, 1, "d", "Date", false, TextAlignment.Left, null); // Добавляем колонки с данными. Один вызов AddList - это одна колонка. pane.AddList("1", "1", new[] { 1.0, 2.0 }, 1, "N2", "header1", true, TextAlignment.Right, null); pane.AddList("2", "2", new[] { 10.0, 20.0 }, 2, "N2", "header2", true, TextAlignment.Right, null); pane.AddList("3", "3", new[] { 100.0, 200.0 }, 3, "N2", "header3", true, TextAlignment.Right, null); } /// <summary> /// Второй вариант таблица с числами и текстом, можно подкрашивать ячейки /// </summary> /// <param name="ctx"></param> private void Variant2(IWindow window) { // Создаем таблицу var pane = window.CreateDataGridPane("MyTable2", "Моя таблица2", 0, "N0", "Номер", true, // включить номер индекса TextAlignment.Left, null, 1, "d", "Date", false, TextAlignment.Left, null); // Создаем данные колонки 1 var series1 = new InteractiveSeries( [ new InteractiveObject(new InteractivePointActive(1, 0) { IsActive = true, Tag = "Текст 1" }), new InteractiveObject(new InteractivePointActive(2, 0) { IsActive = true, Tag = "Текст 2" }), new InteractiveObject(new InteractivePointActive(3, 0) { IsActive = true, Tag = "Текст 3" }), new InteractiveObject(new InteractivePointActive(4, 0) { IsActive = true, Tag = "Текст 4" }), ]); series1.DisplayProperty.Name = "Tag"; // Отображаемое значение, по умолчанию valueY // Создаем данные колонки 2 var series2 = new InteractiveSeries( [ new InteractiveObject(new InteractivePointActive(1, 1) { IsActive = true, ValueYBackColor = ScriptColors.Red, ValueYForeColor = ScriptColors.Black }), new InteractiveObject(new InteractivePointActive(2, 2) { IsActive = true }), new InteractiveObject(new InteractivePointActive(3, 3) { IsActive = true }), new InteractiveObject(new InteractivePointActive(4, 4) { IsActive = true }), ]); // Добавляем колонки с данными. Один вызов AddList - это одна колонка. pane.AddList("1", "1", series1, 1, "N2", "header1", true, TextAlignment.Right, null); pane.AddList("2", "2", series2, 2, "N2", "header2", true, TextAlignment.Right, null); } } }