简体   繁体   English

如何在更新数据网格视图数据(Form-2)后刷新ComboBox数据(Form-1)

[英]How to refresh ComboBox data (Form-1), after updating Data Grid View Data(Form-2)

  • ComboBox - Form 1 ComboBox - 表格1
  • DataGridView - Form 2 DataGridView - 表单2

ComboBox is data-bound to "Quality Setup Table" ComboBox与“质量设置表”数据绑定

ComboBox: Display Members "Quality Code: 401, 402, 403 etc." ComboBox:显示成员“质量代码:401,402,403等”

When I open Form 2 - (DataGridView), perform changes and Close. 当我打开表单2 - (DataGridView)时,执行更改并关闭。 new updated data doesn't reflect in ComboBox. 新的更新数据未在ComboBox中反映出来。

I have to close application and restart to see the newly added data in ComboBox. 我必须关闭应用程序并重新启动以查看ComboBox中新添加的数据。

What should I do to update ComboBox Data with Newly Added/Removed Data in Data Grid View after Closing Form 2. 关闭表单2后,如何更新数据网格视图中新添加/删除数据的ComboBox数据。

Did you try ComboBox.DataBind() when you are updating DataGridView ? 在更新DataGridView时是否尝试过ComboBox.DataBind()

I think you can Find the control from the form and invoke the DataBind() method to refresh the Items of the ComboBox. 我认为你可以从表单中找到控件并调用DataBind()方法来刷新ComboBox的Items。 Hope this helps 希望这可以帮助

I have found solution to my own problem. 我找到了解决自己问题的方法。
In order to update ComboBox with New Data. 为了使用新数据更新ComboBox。

Write this in form 1. 写下表格1。

Form2 form2 = new Form2(); Form2 form2 = new Form2();

form2.showDialog(); form2.showDialog(); // it must be show dialog only not show. //它必须是show对话框才显示。

// below here write code that fills data into comboBox // you can find this code in Form1_Load. //在这下面写下将数据填入comboBox的代码//你可以在Form1_Load中找到这段代码。 // once that is done. //一旦完成 Your comboBox will begin updating data whenever Form2 Closes. 只要Form2关闭,您的comboBox就会开始更新数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 关闭其他表单后如何在数据网格视图中重新加载数据? - How to reload the data in data grid view after closing another form? 刷新按钮 - 插入,删除,更新后刷新数据网格视图 - Refresh button - Refreshing data grid view after inserting, deleting, updating 更新后,数据网格视图将不会刷新 - Data Grid View won't refresh after updating 在另一个表单上更新数据库后刷新另一个表单上的数据表中的数据 - refresh data in data table on another form after updating database on another form 如何在不重新打开的情况下从C#中的其他表单刷新数据网格视图? - How to refresh Data Grid view from other form in c# without reopening? 从其他表单添加数据后,c#实体框架刷新组合框 - c# Entity framework refresh combobox after adding data from another form 在 Windows 表单中自定义数据网格视图 - Customize Data Grid View in Windows Form 如何在数据网格视图窗口窗体中计算第 3 列中的第 1 列和第 2 列 - How to make calculations of column 1 and 2 in column 3 in data grid view windows form 每次选择comboBox后如何清除数据网格视图以检索新数据 - How to clear data grid view after each selection of comboBox to retrive new data 如何在Web窗体中使用linq查询在网格视图中显示数据 - how to display the data in grid view using linq query in web form
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM