[英]How to Refresh Combox After Deleting a Item From It C#
dt = GetId1(ClasSType);
string ClassID = dt.Rows[0][0].ToString();
ncd.DeleteNewNoorWood(ClassID);
typeCb.Refresh();
The TypeCb
is a comboBox control Where I'm having a list of items. TypeCb
是comboBox控件,其中包含项目列表。 When I delete the item using my DeleteNewNorthWood()
method the item is getting deleted from the database, however I can still see it on the form. 当我使用
DeleteNewNorthWood()
方法删除该项目时,该项目正在从数据库中删除,但是我仍然可以在窗体上看到它。
How should I refresh it? 我应该如何刷新?
typeCb.Items.Clear();
for (int i = 0; i < DataTable.Rows.Count; i++)
typeCb.Items.Add(nTable.Rows[i][1].ToString());
This will work 这会起作用
在组合框上再次指定数据源
typeCb.DataSource = yourDataSource;
You should bind your typeCb.DataSource to an ObservableCollection. 您应该将typeCb.DataSource绑定到ObservableCollection。 This way you don't need refresh manually.
这样,您无需手动刷新。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.