473,806 Members | 2,782 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Default value in a combo box

I would like to have the word "Select" as the default option in a combo box
that will retrieve its data from database. I also would like to have the
ability to validate the combo box to ensure that the default option not used.
This combo box is complex bounded.
--
L. A. Jones
Sep 27 '06 #1
3 2623
Add the select option to your data table that you are binding too.
Eg. dt.Rows.Add(new DataRow(-1, "SELECT", "some_other_col umn");
Then check in your validation code for selectedText = "SELECT"
(double check my property names)

Dave wrote:
I would like to have the word "Select" as the default option in a combo box
that will retrieve its data from database. I also would like to have the
ability to validate the combo box to ensure that the default option not used.
This combo box is complex bounded.
--
L. A. Jones
Sep 27 '06 #2
Dave,

Although I find it an horrible solution, can you add with by instance the
DataTable LoadDataRow a datarow.

You have than to use a DataView to set the rows in the combobox in an
ordered way using the Sort.
You should than be sure that all the rows are filled in the "sort" column
and set that column in the LoadDataRow that you use for the "Select" on
spaces.

Most probably you will not succeed in that, because you want your display
member to be the sorted one.
But as you can, than this is easy. There are more ways, but are in my
opinion in fact all even more horrible if you use the value and the
displaymember.

I prefer just a label above the Combobox with in that "Select".

I hope this gives an idea,

Cor

"Dave" <Da**@discussio ns.microsoft.co mschreef in bericht
news:D5******** *************** ***********@mic rosoft.com...
>I would like to have the word "Select" as the default option in a combo box
that will retrieve its data from database. I also would like to have the
ability to validate the combo box to ensure that the default option not
used.
This combo box is complex bounded.
--
L. A. Jones

Sep 27 '06 #3
Or you could use InsertAt

DataTable.Rows. InsertAt(DataRo w, 0)

Sep 27 '06 #4

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

Similar topics

5
17218
by: Harry Haller | last post by:
<select name="cboPlaces" id="cboPlaces"> <option value="3">Countryside</option> <option value="4">Forest</option> <option value="5">Mountain</option> <option value="6">Desert</option> <option value="7">Jungle</option> <option value="7">Swamp</option> <option value="8">River</option> <option value="12">Town</option> <option value="9">Sea</option>
2
5116
by: Hoschi | last post by:
Hello everybody, I'm a complete rookie in MS Access, so please have mercy with my VBA code (in case anything is wrong with it ). I have a listbox that gets its input values from several combo boxes, a small part of the VBA code is the follwing: Private Sub combo1_AfterUpdate() If Me!combo1.Value <> "(All)" Then strSQL9 = "Like '*" & Me!combo1.Value & "*')"
2
10067
by: Todd D. Levy | last post by:
I have a table of Country names & Country codes in alphabetical order. This is a lookup table that a number of other tables use to populate the Country field via a drop down Combo Box on the form(s) for the table(s) in question. The "United States" Country name & the "US" Country code are selected 99% of the time. I would like to have the "United States" & "US" be the default values
2
8242
by: Terry Bickle | last post by:
Please forgive me for using the wrong term here or there. I'm an old Excel 4 macro guy who didn't convert to VB and I'm tinkering with an Access 2000 DB. I'm sure there is a simple Access 101 answer for this. I have a subform which the user selects an item description from a combo box from a table. I want to obtain the cost for the item (another field in the table) also. I've been able to produce the second data field by rewriting the...
3
2009
by: ken | last post by:
Hi, I want to reset the default value of a combo box everytime someone selects something from its list. I have in the after update event combo.defaultvalue = combo.value. Anyhow this works, as long as I don't close the form. Once I close it the new defalut value does not get saved. Is there any way I could save it to the properties of the combo box? Thanks, Using A2k.
0
1997
by: northshore | last post by:
Hello, I am creating a windows application database. I have a primary table 'Individuals' and a lookup table 'Prefixes.' In the Individuals table, I have a column 'PrefixID' that references values of prefixes from the Prefix table based on the PrefixID in the Prefix table. When I load a windows application form, I can display and update data from the primary table. This includes the prefixID value. If I display a combo box with...
1
10931
by: sangram | last post by:
how to select a default value of combo box in run time, i have select some value from database ,depending on this i have to set the value of combox box... advance thanks..
4
2348
by: Torilyn73 | last post by:
I have a combo box set up off a query. I want the default value to be the column heading so I don't have to put a label over it. So far I haven't been able to figure this out. Can anyone tell me if this is possible... and if so..how? Thanks!
2
24892
by: Brad Pears | last post by:
In my vb.net 2005 project I have a few combo boxes where I want to set a default value. I am not binding these combo boxes - I am loading the values directly in code from a dataset. Obviously the default I am settign will be one of the values from teh drop down list.. How do you set a default value for a combo box?? Thanks, Brad
2
6529
kmartinenko
by: kmartinenko | last post by:
Hi everyone, I have several combo boxes on my form, and while I have designated a column head, I cannot figure out how to default to the column head value. What I really want is for all of my combo boxes to default to a selection that is either blank or the column head, so that my users don't see their previous selection when they go and select a value from the drop down list. Also, what would be the best way to enable a user to clear out...
0
9598
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
10623
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10111
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
9192
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
7650
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
6877
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
5683
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3010
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.