本文整理汇总了C#中System.Windows.Forms.Label.GetUpperBound方法的典型用法代码示例。如果您正苦于以下问题:C# Label.GetUpperBound方法的具体用法?C# Label.GetUpperBound怎么用?C# Label.GetUpperBound使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Label
的用法示例。
在下文中一共展示了Label.GetUpperBound方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateGrid
private void CreateGrid(int num)
{
pnlPuzzle.Controls.Clear();
Label[] buttonlabels = new Label[num];
int boxcount = Convert.ToInt32(Math.Sqrt(num));
int width = pnlPuzzle.Width / boxcount;
int height = pnlPuzzle.Height / boxcount;
int left = 0;
int top = 0;
int count = 0;
int y_coord = 0;
int x_coord = 0;
//if (resize == false)
//{
numbers = GenerateNumbers(num);
//}
for (int x = 0; x <= buttonlabels.GetUpperBound(0); x++)
{
buttonlabels[x] = new Label();
buttonlabels[x].Click += LabelClick;
buttonlabels[x].DragOver += LabelDragOver;
buttonlabels[x].MouseDown += LabelMouseDown;
buttonlabels[x].DragDrop += LabelDragDrop;
buttonlabels[x].Font = new Font(FontFamily.GenericSansSerif, 42.0f, FontStyle.Bold);
buttonlabels[x].TextAlign = ContentAlignment.MiddleCenter;
buttonlabels[x].AllowDrop = true;
if (x== buttonlabels.GetUpperBound(0))
{
buttonlabels[x].BorderStyle = BorderStyle.None;
buttonlabels[x].BackColor = Color.DarkGray;
}
else
{
buttonlabels[x].BorderStyle = BorderStyle.Fixed3D;
buttonlabels[x].BackColor = Color.White;
}
buttonlabels[x].Width = width;
buttonlabels[x].Height = height;
if (count == 0)
{
buttonlabels[x].Location = new Point(0, top);
}
else
{
if (count == boxcount)
{
left = 0;
top += height;
count = 0;
buttonlabels[x].Location = new Point(0, top);
y_coord++;
x_coord = 0;
}
else
{
buttonlabels[x].Location = new Point(left + width, top);
left += width;
x_coord++;
}
}
count++;
buttonlabels[x].Tag = x_coord.ToString() + "," + y_coord.ToString();
if (x < buttonlabels.GetUpperBound(0))
{
buttonlabels[x].Text = numbers[x].ToString();
}
pnlPuzzle.Controls.Add(buttonlabels[x]);
}
}