【发布时间】:2024-01-08 10:35:02
【问题描述】:
我正在尝试更新“总机”上的 datagridview 以解决并发问题。当某些过程完成时,总机有许多复选框可以选中。当我单击已编辑记录上的复选框时,我收到并发错误,因为 dgv 不是最新的。
我试过这样做:
How to refresh datagridview when closing child form?
无济于事,因为它在我的整个项目中引发了其他错误。
有关如何在关闭另一个表单的表单上刷新我的交换机上的 datagridview 的任何帮助都会很棒。
谢谢
public partial class frmSwitch : Form
{
public frmSwitch()
{
//'add a label and a buttom to form
InitializeComponent();
}
public void PerformRefresh()
{
this.propertyInformationBindingSource.EndEdit();
this.propertyInformationTableAdapter.Fill(this.newCityCollectionDataSet.PropertyInformation);
this.propertyInformationDataGridView.Refresh() }
}
public partial class frmSummary : Form
{
frmSwitch _owner;
public frmSummary(frmSwitch owner)
//public frmSummary()
{
InitializeComponent();
_owner = owner;
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmSummary_FormClosing);
}
private void frmSummary_FormClosing(object sender, FormClosingEventArgs e)
{
_owner.PerformRefresh();
}
这就是我试图做的,但是当我需要打开 Form2 时,它在其他情况下引起了问题。该问题具体出现在表格2的原始打开中,如下所示:
private void propertyInformationDataGridView_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
{
System.Data.DataRowView SelectedRowView;
newCityCollectionDataSet.PropertyInformationRow SelectedRow;
SelectedRowView = (System.Data.DataRowView)propertyInformationBindingSource.Current;
SelectedRow = (newCityCollectionDataSet.PropertyInformationRow)SelectedRowView.Row;
frmSummary SummaryForm = new frmSummary();
SummaryForm.LoadCaseNumberKey(SelectedRow.CaseNumberKey, true, null);
SummaryForm.Show();
}
【问题讨论】:
标签: c# winforms datagridview refresh