473,396 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ComboBox Blank Entry

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
Feb 11 '06 #1
5 24951
"Steve B." <St****@discussions.microsoft.com> wrote in message
news:A9**********************************@microsof t.com...
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


Not sure what you mean by whitespace - if you add a blank entry to a
ComboBox, that's exactly what it will be - a blank entry...
Feb 12 '06 #2
On Sat, 11 Feb 2006 14:32:31 -0800, "Steve B."
<St****@discussions.microsoft.com> wrote:
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
Feb 12 '06 #3
Thanks 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" wrote:
On Sat, 11 Feb 2006 14:32:31 -0800, "Steve B."
<St****@discussions.microsoft.com> wrote:
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

Feb 12 '06 #4
On Sun, 12 Feb 2006 11:56:03 -0800, "Steve B."
<St****@discussions.microsoft.com> wrote:
Thanks 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" wrote:
On Sat, 11 Feb 2006 14:32:31 -0800, "Steve B."
<St****@discussions.microsoft.com> wrote:
>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

Change "Top Item" to "" and you will get a blank entry in the first
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
Feb 12 '06 #5
I'll try it thank you Otis

--Steve

"Otis Mukinfus" wrote:
On Sun, 12 Feb 2006 11:56:03 -0800, "Steve B."
<St****@discussions.microsoft.com> wrote:
Thanks 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" wrote:
On Sat, 11 Feb 2006 14:32:31 -0800, "Steve B."
<St****@discussions.microsoft.com> wrote:

>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

Change "Top Item" to "" and you will get a blank entry in the first
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

Feb 12 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: ChadDiesel | last post by:
My basic question is why does my print report button on my subform print a blank report when my cursor is on a blank entry line? Here is a more detailed explanation of my problem. I have a...
8
by: Krul | last post by:
I like to have a blank entry at top of the combobox list, so the user is able to clear the combobox. Right now, the form displays a empty entry on load, but after chosen a value once, it is not...
3
by: Craig G | last post by:
i use the following to populate a combo in a datagrid but was wondering how i would add a blank entry to the top of the combo so that on first load it has no value selected? <asp:DropDownList...
5
by: James P. | last post by:
Hello, For my new Windows application, all I want is to create an initial form to demo to the user to show them how it looks like with some data on it. So I figure the fastest way is to create...
3
by: JD Williams | last post by:
Greetings, I have a combobox that I have data added to when I defined it. Like so: 'cbDCs ' Me.cbDCs.Items.AddRange(New Object() {"ADC1", "ADC2", "ADC3"}) Me.cbDCs.Location = New...
4
by: Jerad Rose | last post by:
I'm baffled by this -- is there not a typed object used for ComboBox Items? Best I can tell, all of the methods for ComboBox that accept an Item are of type Object. Why in the world is a...
1
by: HotKgon | last post by:
I would like appreciate some help on a issue I am having at the moment. On "Form1" I have a button which opens up "Form2". "Form2" is used to enter in GP data. The issue is that When "Form2"...
3
by: sreegans | last post by:
Hi... how to avoid multiple entry display in combo box? ie) if we are displaying the TV List in Combo... combo1.additem "samsung" combo1.additem "onida" combo1.additem "samsung"
6
by: sartemieff | last post by:
I am using MS Access 2007 on an XP platform. I have forms (split and single) with listboxes. If a listbox is bound to a field that can contain a null, I would like the listbox to include a blank...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.