本文介绍了C#Databound ComboBox自动更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个绑定到数据库表的组合框。
当用户向表中插入一个新数据时,我希望组合框被自动更新以显示这些数据,但是我不知道我该怎么做。

I have a combobox bound to a database table.When the user inserts a new piece of data into the table, I want the combobox to be automatically updated to display this data, however I am unsure of how I would go about doing this.

帮助将非常感激。

推荐答案

我在我的程序中有类似的东西

I have something similar to this in a program of mine.

每当我的datagridview更新时,我清空组合框并重新填充。

Whenever my datagridview is updated, I empty the combobox and refill it.

(我现在没有我的代码,但这是一般的想法):

Something along the lines of (I don't have my code available right now, but this is the general idea):

if (!combobox.isempty())
{
    combobox.clear()
}

// Fill combobox here

这篇关于C#Databound ComboBox自动更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-19 05:04