473,387 Members | 1,321 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,387 software developers and data experts.

Unselected Combo-Value stored...

Hi!
I've just written a form. In this form, I extract some data from the db
for a given combobox when loading the form. The problem is this, when I
fail to select an item from this combobox and store my changes, I still
observe that the first combobox-item is stored in my new table (that
means, it is chosen automatically). Is there any way I can avoid this?
I have the following in my load_method:

private void Form1_Load(object sender, EventArgs e)
{
commandTxt = "select no, name1 from ...";
tblDeliver = SelectStatementsData(commandTxt);//gets the rows
if (tblDeliver != null)
{
this.comboBoxDeliver.DataSource = tblDeliver;

//names are displayed in combo, but works with no (id)
this.comboBoxDeliver.ValueMember = "no";
this.comboBoxDeliver.DisplayMember = "name1";
}
else
MessageBox.Show(ExceptionMsg);

}

Tried to manipulate it in SelectedIndexChanged, but to no avail:
private void comboBoxDeliver_SelectedIndexChanged(object sender,
EventArgs e)
{
if (comboBoxDeliver.SelectedItem.ToString() != null)
{
comboBoxDeliver.SelectedValue.ToString();
}
else
MessageBox.Show("Deliverer does not exist");

------------------------------------------
How can I manipulate it so that nothing could appear in the first line
of combobox by loading? or/and
How can I make sure that if I select nothing from the combo, nothing
will be stored in the db on saving?

Thanks in advance,
Stropher

Nov 17 '05 #1
2 1743
Jan
Hi Stropher,

There will always be a value selected your forms ComboBox because it
does not support all the modes that a WinForms ComboBox supports,
namely it only works in DropDownList mode.

The usual way of dealing with this problem is to put a placeholder
value in your ComboBox like <Please Select a Thing>. You can then
ignore this value or use it to trigger a validation event by marking it
as the "Default" value in a validator and disallowing it to be
submitted.

Hope that helps,
Jan

Nov 17 '05 #2
Hi Jan!

Thanks for your answer, this is a very good idea..., I'll try it.

I did also try the very last statements of HyperX, which did work
(though an interesting solution!):
http://groups.google.com/group/micro...9e5611a70ba2fe

Regards,
Stropher

Nov 17 '05 #3

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

Similar topics

0
by: Krisa | last post by:
Hello all, I just discovered something (stop me if you've heard this before....) that was causing me a significant performance hit when opening a form with subforms. To speed up loading the...
1
by: TheThrill | last post by:
I'm trying to develop a few combo boxes. When a user selects a choice in Combo box "A" they have the choices "1, 2, 3, 4". Say they pick 3. They must then go to combo box "B" and when they pick 3...
1
by: Jeff Smith | last post by:
Hi This is a repost due to no responses Here's a problem I've encountered with Access 2003 which has got me to redesign how I get the row source in a second combo box using the first combo...
3
by: hmiller | last post by:
Hey everyone, I am having a hell of a time trying to set this menu system up. Here's what I'm trying to do. Combo Box One; is populated by names under properties "row source" "Phase 1"...
3
by: manning_news | last post by:
Using 2003. How do I tell if a selected item on a multi-select listbox is now unselected? If a user unselects an item, I want to prompt them that they've unselected it. No prompt if they're...
9
by: Edwinah63 | last post by:
Hi everyone, Please let there be someone out there who can help. I have two BOUND combo boxes on a continuous form, the second being dependent on the first. I have no problem getting the...
2
by: kiranmn75 | last post by:
I want to dynamically populate a combo box through javascript. Data is coming from a array. Sometimes data list may contain items in excess of 2000. Explorer takes more than 5 seconds to...
1
by: lawton | last post by:
Source: this is an access 2003 question My knowledge level: reading books, internet, and trial & error; no formal training I'm trying to get a running sum of what's filtered in a subform which is...
3
rhitam30111985
by: rhitam30111985 | last post by:
Hi all.. i am trying to create a combo with the pop down list being modfied in real time as i type each character : import gtk window=gtk.Window(gtk.WINDOW_TOPLEVEL)...
1
by: benoypaul | last post by:
Hi, A webpage contains a list box. I wish to know how to transfer all values in a list box(including unselected) to antother php page for processing . Thanks in advance
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.