I have a combobox with some items added via form, by the Items (Collection) property.
I would like to be able to leave to the user, typing new texts in this combobox, which in my case, is a combobox of product categories.
I created a code that adds the typed text to the combobox, but it does not stay there when the form is restarted, my question is, can you add an item and make it stay in the items?
Note: There is no way I can use a database for this.
My code:
private void btnIncluirItens_Click(object sender, EventArgs e)
{
// para inserir na última posição
int cnt = cbCategoriaProduto.Items.Count;
if (cbCategoriaProduto.Text != String.Empty)
{
cbCategoriaProduto.Items.Insert(cnt, cbCategoriaProduto.Text);
}
else
{
cbCategoriaProduto.Items.Insert(cnt, "Item " + cnt);
}
cbCategoriaProduto.Text = ""; //limpa a caixa de texto após a inclusão
}