Replies: 1 comment 1 reply
-
You want to use Here is an example: using System.Data;
using Terminal.Gui;
namespace Test
{
public class Program
{
static void Main()
{
Application.Init();
var w = new Window() { Title = "My Window" };
var tv = new TableView
{
Width = Dim.Fill(),
Height = Dim.Fill(),
};
var dt = new DataTable();
var col = dt.Columns.Add("fish");
dt.Rows.Add("A");
dt.Rows.Add("B");
dt.Rows.Add("C");
tv.Table = dt;
var pink = CreateScheme(Color.BrightMagenta);
var normal = CreateScheme(Color.White);
var colStyle = tv.Style.GetOrCreateColumnStyle(col);
colStyle.ColorGetter = (e) =>
{
return e.CellValue == "B" ? pink : normal;
};
w.Add(tv);
Application.Run(w);
Application.Shutdown();
return;
}
private static ColorScheme CreateScheme(Color foreground)
{
return new ColorScheme
{
Normal = new Terminal.Gui.Attribute(foreground, Color.Blue),
// flip color for selected nodes
Focus = new Terminal.Gui.Attribute(Color.Blue, foreground),
HotNormal = new Terminal.Gui.Attribute(foreground, Color.Blue),
HotFocus = new Terminal.Gui.Attribute(Color.Blue, foreground),
Disabled = new Terminal.Gui.Attribute(foreground, Color.Blue),
};
}
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Working with v1 recently and I need a way to render the text within a cell in a different color depending on its value. Any help appreciated!
Beta Was this translation helpful? Give feedback.
All reactions