PDA

View Full Version : داشتن یک جدول گرافیکی در صفحه



mammad_asir
پنج شنبه 15 اردیبهشت 1390, 15:01 عصر
میخوام یک جدول n8n در فرم داشته باشم و بتونم به رنگ و ... هر خونش به صورت ماتریس دست رسی داشته باشم مثلا یک چیز مثا صفحه شطرنج ممنون

exlord
پنج شنبه 15 اردیبهشت 1390, 20:24 عصر
public class Cell:Control
{
public Cell()
{
this.Width = 50;
this.Height = 50;
}

protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.DrawRectangle(Pens.Black, 0, 0, this.Width - 1, this.Height - 1);
}
}


public class Table:UserControl
{
private FlowLayoutPanel _layOutPanel;
private GroupBox _p;//Border
public Table()
{
_p = new GroupBox() { Dock = DockStyle.Fill};
this.Controls.Add(_p);
_layOutPanel = new FlowLayoutPanel();
_layOutPanel.Dock = DockStyle.Fill;
_p.Controls.Add(_layOutPanel);
this.Width = 200;
this.Height = 200;
}

protected override void OnControlAdded(ControlEventArgs e)
{
if (e.Control != _p)
{
this.Controls.Remove(e.Control);
_layOutPanel.Controls.Add(e.Control);
}
}
}

Table t = new Table() { Top = 100,Left = 100};
t.Controls.Add(new Cell());
t.Controls.Add(new Cell());
t.Controls.Add(new Cell());
this.Controls.Add(t);