本文介绍了无缝网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好!我正在尝试创建一个无缝的网格视图以在我的C#应用程序中显示数据.我希望能够在背景图片上方看到数字-没有网格线或框等.仅显示数字.
有任何想法吗?
非常感谢您提前抽出时间,
Dusty
Hello all! I''m trying to create a seamless grid view to display data within my C# application. I want to be able to see the numbers on top of my background image- no gridlines or boxes, etc. Just the number display.
Any ideas?
I appreciate your time in advance,
Dusty
推荐答案
protected List<string> Colors;
protected Color RandomColor()
{
Color ret;
/* Truncated Code */
return ret;
}
private void Form1_Load(object sender, EventArgs e)
{
Colors = new List<string>();
Grid8x8.Margin = new System.Windows.Forms.Padding(0);
Grid8x8.Padding = new System.Windows.Forms.Padding(0);
Grid8x8.BorderStyle = BorderStyle.FixedSingle;
Initialize();
}
private void Initialize()
{
Colors.Clear();
Grid8x8.Controls.Clear();
int i;
for (i = 0; i < 64; i++)
{
cell = new Label();
cell.Text = i.ToString();
cell.AutoSize = false;
cell.BorderStyle = BorderStyle.None;
cell.TextAlign = ContentAlignment.MiddleCenter;
cell.Width = 50;
cell.Height = 50;
cell.Margin = new System.Windows.Forms.Padding(0);
currentColor = RandomColor();
previousColor = currentColor;
cell.BackColor = currentColor;
Grid8x8.Controls.Add(cell);
Colors.Add(currentColor.ToString());
}
}
由于List是从0开始的索引,而不是多维数组,因此可以肯定地说,如果X == CurrentCellIndex,则X + 8等于直接在CurrentCellIndex下面的单元格.
希望这会有所帮助,
-ArtificerGM
Since the List is 0-based index instead of a multi-dimensional array its safe to say that if X == CurrentCellIndex then X + 8 will equal the Cell Directly below the CurrentCellIndex.
Hope this helps,
-ArtificerGM
这篇关于无缝网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!