C# を使用して座席予約ソフトウェアを作成していますが、多くの座席を即座に描画する方法がわかりません。私は3つの方法を試しています..
- ユーザーコントロールの使用
public void DrawUsercontrol(int x, int y)
{
int space = 4;
int SeatLimit = 165;
int RowSeatLimit = 15;
for (var i = 1; i < SeatLimit; i++)
{
UserControl1 ctrl = new UserControl1();
ctrl.Size = new System.Drawing.Size(25, 25);
ctrl.Location = new Point(x + space, y);
if (i % RowSeatLimit == 0)
{
x = 1;
y = y + 25 + space;
}
x = x + 25 + space;
ctrl.label1.Text = i.ToString();
ctrl.label1.Click += new EventHandler(label1_Click);
panel1.Controls.Add(ctrl);
}
}
「パネル」コントロールの使用
public void DrawingPanel(int x, int y) { Panel myPanel = new Panel(); int width = 16; int height = 16; myPanel.Size = new Size(width, height); myPanel.BackColor = Color.White; myPanel.Location = new Point(x, y); Label mylabel = new Label(); mylabel.Text = "4"; myPanel.Controls.Add(mylabel); myPanel.BackColor = Color.YellowGreen; // this.Controls.Add(myPanel); panel1.Controls.Add(myPanel); }
Graphics を使用して Rectangle を描画する
public void DrawingSquares(int x, int y) { SolidBrush myBrush = new SolidBrush(System.Drawing.Color.Red); Graphics graphicsObj; graphicsObj = this.panel1.CreateGraphics(); Rectangle myRectangle = new Rectangle(x, y, 30, 30); graphicsObj.FillRectangle(myBrush, myRectangle); graphicsObj.Dispose(); }
最初のオプションを参照しますが、遅すぎます。また、どのように判断すればよいですか?