如何及时刷新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);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
光点科技
2023-08-15 广告
2023-08-15 广告
通常情况下,我们会按照结构模型把系统产生的数据分为三种类型:结构化数据、半结构化数据和非结构化数据。结构化数据,即行数据,是存储在数据库里,可以用二维表结构来逻辑表达实现的数据。最常见的就是数字数据和文本数据,它们可以某种标准格式存在于文件...
点击进入详情页
本回答由光点科技提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询