G
Guest
Without adding whitespace to the ComboBox datasource is there a way I can add
a blank entry or, a reset entry, to the ComboBox dropdown
Thanks
Steve
a blank entry or, a reset entry, to the ComboBox dropdown
Thanks
Steve
Without adding whitespace to the ComboBox datasource is there a way I can
add
a blank entry or, a reset entry, to the ComboBox dropdown
If you mean you want to add a value to index zero of the combo box,Without adding whitespace to the ComboBox datasource is there a way I can add
a blank entry or, a reset entry, to the ComboBox dropdown
Thanks
Steve
Otis Mukinfus said:If you mean you want to add a value to index zero of the combo box,Without adding whitespace to the ComboBox datasource is there a way I can add
a blank entry or, a reset entry, to the ComboBox dropdown
Thanks
Steve
the way to do that is to populate the combo from the data source and
then add it by doing this:
private void FillButton_Click(object sender, EventArgs e)
{
string[] items = { "One", "Two", "Three" };
TestComboBox.Items.AddRange(items);
TestComboBox.Items.Insert(0, "Top Item");
TestComboBox.SelectedIndex = 0;
}
Otis Mukinfus
http://www.otismukinfus.com
http://www.tomchilders.com
Change "Top Item" to "" and you will get a blank entry in the firstThanks Mark/Otis for replying
My datasource is a database table.
Lets say the datasource for the CB dropdown is a database table of colors.
If the user selects the color "Red" in the dropdown and then changes his mind
later and decides not to select a any kind of color his only choice is to
backspace to remove his previous "Red" selection. I wanted to give the user
a choice to select a blank entry in the dropdown menu. I didn't want to add
a blank row to the database (bad practice).
Mark, I'm going to do some tests regarding your code
Thanks
Steve
Otis Mukinfus said:If you mean you want to add a value to index zero of the combo box,Without adding whitespace to the ComboBox datasource is there a way I can add
a blank entry or, a reset entry, to the ComboBox dropdown
Thanks
Steve
the way to do that is to populate the combo from the data source and
then add it by doing this:
private void FillButton_Click(object sender, EventArgs e)
{
string[] items = { "One", "Two", "Three" };
TestComboBox.Items.AddRange(items);
TestComboBox.Items.Insert(0, "Top Item");
TestComboBox.SelectedIndex = 0;
}
Otis Mukinfus
http://www.otismukinfus.com
http://www.tomchilders.com
Otis Mukinfus said:Change "Top Item" to "" and you will get a blank entry in the firstThanks Mark/Otis for replying
My datasource is a database table.
Lets say the datasource for the CB dropdown is a database table of colors.
If the user selects the color "Red" in the dropdown and then changes his mind
later and decides not to select a any kind of color his only choice is to
backspace to remove his previous "Red" selection. I wanted to give the user
a choice to select a blank entry in the dropdown menu. I didn't want to add
a blank row to the database (bad practice).
Mark, I'm going to do some tests regarding your code
Thanks
Steve
Otis Mukinfus said:On Sat, 11 Feb 2006 14:32:31 -0800, "Steve B."
Without adding whitespace to the ComboBox datasource is there a way I can add
a blank entry or, a reset entry, to the ComboBox dropdown
Thanks
Steve
If you mean you want to add a value to index zero of the combo box,
the way to do that is to populate the combo from the data source and
then add it by doing this:
private void FillButton_Click(object sender, EventArgs e)
{
string[] items = { "One", "Two", "Three" };
TestComboBox.Items.AddRange(items);
TestComboBox.Items.Insert(0, "Top Item");
TestComboBox.SelectedIndex = 0;
}
Otis Mukinfus
http://www.otismukinfus.com
http://www.tomchilders.com
row. Then when the user selects an item from the ComboBox you can do
the appropriate thing based on the selected index.
Otis Mukinfus
http://www.otismukinfus.com
http://www.tomchilders.com
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.