I have a ComboBox
with a DataSource
set to application settings as follows
public DetailsForm()
{
InitializeComponent();
this.comboBox1.DataSource = TextSelectionSettings.Default.categories;
}
But I want users to add extra items to the combo box if they need to at runtime. So I just made a simple click event on a textbox to test adding a new string to the list.
private void textBox1_MouseClick(object sender, MouseEventArgs e)
{
TextSelectionSettings.Default.categories.Add("test");
TextSelectionSettings.Default.Save();
}
However the ComboBox
doesn't show the new string I added to the settings.
How can I refresh the ComboBox
to show the changes in the settings?
Refresh()
function on the combo box did not work.- setting the
DataSource
again did not work either. - I cannot add the
Item
directly toComboBox
usingItems.Add()
method because theDataSource
is set.