473,698 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 25026
"Steve B." <St****@discuss ions.microsoft. com> wrote in message
news:A9******** *************** ***********@mic rosoft.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****@discuss ions.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_Clic k(object sender, EventArgs e)
{
string[] items = { "One", "Two", "Three" };

TestComboBox.It ems.AddRange(it ems);
TestComboBox.It ems.Insert(0, "Top Item");
TestComboBox.Se lectedIndex = 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****@discuss ions.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_Clic k(object sender, EventArgs e)
{
string[] items = { "One", "Two", "Three" };

TestComboBox.It ems.AddRange(it ems);
TestComboBox.It ems.Insert(0, "Top Item");
TestComboBox.Se lectedIndex = 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****@discuss ions.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****@discuss ions.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_Clic k(object sender, EventArgs e)
{
string[] items = { "One", "Two", "Three" };

TestComboBox.It ems.AddRange(it ems);
TestComboBox.It ems.Insert(0, "Top Item");
TestComboBox.Se lectedIndex = 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****@discuss ions.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****@discuss ions.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_Clic k(object sender, EventArgs e)
{
string[] items = { "One", "Two", "Three" };

TestComboBox.It ems.AddRange(it ems);
TestComboBox.It ems.Insert(0, "Top Item");
TestComboBox.Se lectedIndex = 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
2445
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 form that contains shipment destination information and a subform that contains boxes for that shipment. The main form is a table called Ship_Info, and the subform is a table called Label_Info. They both contain and are linked by a field called...
8
9986
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 possible to select a blank entry again. The only way is to delete the string manually and press enter.
3
4182
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 id=cboIntensityAdd runat="server" Width="149px" CssClass="yarGridCombo" DataValueField="CODE" DataTextField="PAININTENSITY" DataSource="<%# FillPainIntensityCombo() %>"></asp:DropDownList> FillPainIntensityCombo simply selects all records from a...
5
25837
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 some comboBox-es to show some data on them manually entered in the code without connecting to the database yet. It should be simple but somehow I can't make it work. First, I drag a comboBox from the ToolBox to the form. Then,
3
1266
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 System.Drawing.Point(400, 48) Me.cbDCs.Name = "cbDCs" Me.cbDCs.Size = New System.Drawing.Size(184, 21)
4
6663
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 common/standard .NET control accepting an Object as a parameter type? In Web Forms, there is a ListItem object that can be passed in to add/retrieve objects from a DropDownItems collection. I searched Google groups, and all the solutions I'm finding...
1
1346
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" opens, it always goes to the first GP in the table. Is there anyway which I can make it so when "Form2" loads, it automatically goes to create a new blank record instead of going to the first record in the table? I've posted up the Form_Load code...
3
1529
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
3511
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 entry at the top of the list so it is readily apparent when the bound field contains a null and so that the user can deselect a value and revert to a null value. I would also like the listbox to display the entry that corresponds to the value of the...
0
8608
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9029
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8867
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7732
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6522
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2332
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2006
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.