如何及时刷新DATAGRIDVIEW的数据,在线等
2个回答
2015-07-20
展开全部
private void Form1_Load(object sender, EventArgs e)
{
regionTableAdapter1.Fill(northwind1.Region);
bindingSource1.DataSource = northwind1.Region;
bindingSource1.PositionChanged += new EventHandler(bindingSource1_PositionChanged);
dataGridView1.DataSource = bindingSource1;
bindingSource1_PositionChanged(bindingSource1, null);
}
void bindingSource1_PositionChanged(object sender, EventArgs e)
{
try
{
Northwind.RegionRow r = ((bindingSource1.Current as DataRowView).Row as DataRow) as Northwind.RegionRow;
textBox1.Text = r.RegionID.ToString();
textBox2.Text = r.RegionDescription;
}
catch
{
}
}
private void button1_Click(object sender, EventArgs e)
{
Northwind.RegionRow r = northwind1.Region.NewRegionRow();
r.RegionID = int.Parse(textBox1.Text);
r.RegionDescription = textBox2.Text;
northwind1.Region.AddRegionRow(r);
regionTableAdapter1.Update(northwind1.Region);
}
private void button2_Click(object sender, EventArgs e)
{
Northwind.RegionRow r = ((bindingSource1.Current as DataRowView).Row as DataRow) as Northwind.RegionRow;
r.RegionDescription = textBox2.Text;
regionTableAdapter1.Update(northwind1.Region);
}
private void button3_Click(object sender, EventArgs e)
{
Northwind.RegionRow r = ((bindingSource1.Current as DataRowView).Row as DataRow) as Northwind.RegionRow;
r.Delete();
regionTableAdapter1.Update(northwind1.Region);
}
{
regionTableAdapter1.Fill(northwind1.Region);
bindingSource1.DataSource = northwind1.Region;
bindingSource1.PositionChanged += new EventHandler(bindingSource1_PositionChanged);
dataGridView1.DataSource = bindingSource1;
bindingSource1_PositionChanged(bindingSource1, null);
}
void bindingSource1_PositionChanged(object sender, EventArgs e)
{
try
{
Northwind.RegionRow r = ((bindingSource1.Current as DataRowView).Row as DataRow) as Northwind.RegionRow;
textBox1.Text = r.RegionID.ToString();
textBox2.Text = r.RegionDescription;
}
catch
{
}
}
private void button1_Click(object sender, EventArgs e)
{
Northwind.RegionRow r = northwind1.Region.NewRegionRow();
r.RegionID = int.Parse(textBox1.Text);
r.RegionDescription = textBox2.Text;
northwind1.Region.AddRegionRow(r);
regionTableAdapter1.Update(northwind1.Region);
}
private void button2_Click(object sender, EventArgs e)
{
Northwind.RegionRow r = ((bindingSource1.Current as DataRowView).Row as DataRow) as Northwind.RegionRow;
r.RegionDescription = textBox2.Text;
regionTableAdapter1.Update(northwind1.Region);
}
private void button3_Click(object sender, EventArgs e)
{
Northwind.RegionRow r = ((bindingSource1.Current as DataRowView).Row as DataRow) as Northwind.RegionRow;
r.Delete();
regionTableAdapter1.Update(northwind1.Region);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
万山数据
2024-11-14 广告
2024-11-14 广告
实时数仓处理是我们北京万山数据科技有限公司数据处理能力的核心之一。它基于先进的流处理技术,能够实时捕获、处理和分析海量数据,确保数据的时效性和准确性。通过构建高效的实时数据管道,我们能够实现数据的即时入库与查询,为业务决策提供强有力的支持。...
点击进入详情页
本回答由万山数据提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询