gpt4 book ai didi

c# - EPG 时间线控制

转载 作者:太空宇宙 更新时间:2023-11-03 10:56:12 25 4
gpt4 key购买 nike

我想创建一个显示 EPG 的应用程序,如下图所示: http://gonedigital.net/wp-content/uploads/SonyEPG.jpg

我需要一个控件来显示时间轴。我考虑过使用 datagridview,但我认为它不合适,因为无法为每一行设置列大小。有没有可以使用的自定义控件?如果没有,对如何开始有什么建议吗?谢谢

编辑:

我已经使用了 TableLayoutPanel,它适用于少量数据。更大的数据变得太小了。我搜索并找到了SourceGrid这是非常快速和灵活的。

最佳答案

当然...用新表单尝试这个 TableLayoutPanel 示例。忽略颜色,因为它们很讨厌;而是关注网格布局以及标签如何跨列。这只是标题加上前三行。调整表格的宽度并注意比例是如何保持的: Television Guide via a TableLayoutPanel

public partial class Form1 : Form
{

private TableLayoutPanel grid = new TableLayoutPanel();

public Form1()
{
InitializeComponent();

grid.RowCount = 9;
for (int i = 1; i <= grid.RowCount; i++)
{
grid.RowStyles.Add(new RowStyle(SizeType.Percent, 42)); // all the same percent, the value doesn't matter
}
grid.ColumnCount = 16;
for (int i = 1; i <= grid.ColumnCount; i++)
{
grid.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 42)); // all the same percent, the value doesn't matter
}
grid.Dock = DockStyle.Fill;
this.Controls.Add(grid);

this.BackColor = Color.Black;
ExampleGrid();
}

private void ExampleGrid()
{
grid.Controls.Clear();

AddEntry("Today", 0, 1, 3, Color.White, Color.Black, false);
AddEntry("| 14:00", 0, 4, 3, Color.White, Color.Black, false);
AddEntry("| 14:30", 0, 7, 3, Color.White, Color.Black, false);
AddEntry("| 15:00", 0, 10, 3, Color.White, Color.Black, false);
AddEntry("| 15:30", 0, 13, 3, Color.White, Color.Black, false);

AddEntry("050", 1, 0, 1, Color.White, Color.Black, false);
AddEntry("BBC HD", 1, 1, 3, Color.White, Color.Black, false);
AddEntry("Mary Poppins", 1, 4, 8, Color.Black, Color.White, true);
AddEntry("Dustbin Baby -->", 1, 12, 4, Color.White, Color.LightGray, true);

AddEntry("051", 2, 0, 1, Color.White, Color.Black, false);
AddEntry("ITV1 HD", 2, 1, 3, Color.White, Color.Black, false);
AddEntry("Rosemary and Thyme", 2, 4, 6, Color.White, Color.Gray, true);
AddEntry("Agatha Christie's Poirot -->", 2, 10, 6, Color.White, Color.LightGray, true);

AddEntry("052", 3, 0, 1, Color.White, Color.Black, false);
AddEntry("Channel 4 HD", 3, 1, 3, Color.White, Color.Black, false);
AddEntry("The Green Berets", 3, 4, 5, Color.White, Color.Gray, true);
AddEntry("Coach Trip", 3, 9, 3, Color.White, Color.LightGray, true);
AddEntry("Countdown -->", 3, 12, 4, Color.White, Color.LightGray, true);

// ... etc ...
}

private void AddEntry(string text, int row, int col, int columnSpan, Color foreColor, Color backColor, bool border)
{
Label lbl = new Label();
lbl.Text = text;
lbl.AutoSize = false;
lbl.AutoEllipsis = true;
lbl.ForeColor = foreColor;
lbl.BackColor = backColor;
lbl.Dock = DockStyle.Fill;
lbl.BorderStyle = border ? BorderStyle.FixedSingle : BorderStyle.None;
lbl.TextAlign = ContentAlignment.MiddleLeft;
grid.Controls.Add(lbl, col, row);
grid.SetColumnSpan(lbl, columnSpan);
}

}

关于c# - EPG 时间线控制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19406017/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com