[英]Add to dataGridView by C# code
我想添加每一次計數器通過使用new BindingSource增加新行,但它在行“最后修改的”上添加
這是我的代碼:
public class PacketWrapper
{
public string p;
public int Count { get; set; }
public string Timeval { get { return "l"; } }
public string LinkLayerType { get { return"2"; } }
public int Length { get { return p.Length; } }
public PacketWrapper(int count, string p)
{
this.Count = count;
this.p = p;
}
}
BindingSource bs = new BindingSource();
PacketWrapper p;
private void Form1_Load(object sender, EventArgs e)
{
dataGridView1.DataSource = bs;
p = new PacketWrapper(1, "djd");
Timer MyTimer = new Timer();
MyTimer.Interval = (450); // 45 mins
MyTimer.Tick += new EventHandler(MyTimer_Tick);
MyTimer.Start();
}
private void MyTimer_Tick(object sender, EventArgs e)
{
for (int i = 1; i < 11; i++)
{
p.Count = i;
bs.DataSource = p;
}
}
如何使用此代碼每次添加新行?
更換
bs.DataSource = p;
同
bs.Add(p);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.