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

Combobox selectedvalue = null

Jac

Hey,

How can I set the display value of a combobox empty? But all the posible
choices are available when I push the trianglebut.

Sometimes if I set the selecteditem = null it works, other times it don't
work and sometimes I receive an error 'Additional information: Value cannot
be null'.

this.CmbDataSource = SoortKwijtingList.Items; // Arraylist
this.Cmb.DisplayMember = "Omschrijving";
this.Cmb.ValueMember = "Id";
this.Cmb.SelectedItem = null;

I don't understand that, what is so unstable? Has it something to do with
the moment of databinding?

Thanks in advance
jac

Nov 17 '05 #1
2 43421
Hi Jac,

Set ComboBox.SelectedIndex = -1;
On Thu, 28 Apr 2005 22:34:18 +0200, Jac <Ja*@discussions.microsoft.com> wrote:

Hey,

How can I set the display value of a combobox empty? But all the posible
choices are available when I push the trianglebut.

Sometimes if I set the selecteditem = null it works, other times it don't
work and sometimes I receive an error 'Additional information: Value cannot
be null'.

this.CmbDataSource = SoortKwijtingList.Items; // Arraylist
this.Cmb.DisplayMember = "Omschrijving";
this.Cmb.ValueMember = "Id";
this.Cmb.SelectedItem = null;

I don't understand that, what is so unstable? Has it something to do with
the moment of databinding?

Thanks in advance
jac


--
Happy coding!
Morten Wennevik [C# MVP]
Nov 17 '05 #2
Jac
Hey,

I have still something strange.

When I made my choice in the combobox and push the Cancel-button then I want
to show the previous values (the values I had before) and I do this now like
this :

f (kwijting.SoortKwijting == null )
this.Cmb.SelectedIndex = -1;
else
this.Cmb.SelectedValue = kwijting.SoortKwijting.Id;

This works fine. But then I push the Add-button (add new record). I want to
clean up all the values in the screen (want all my comboboxes, textfields
etc. are empty, so I can start to fill in the screen).
So, for the comboboxes I do this :

this.Cmb.SelectedIndex = -1;

If I look in 'QuickWatch" he changes my selectedindex not to -1, but to 1.
And so he gives me always the first choice in view of the combobox.

When I do it like this :
this.Cmb.SelectedIndex = -1;
this.Cmb.SelectedValue= -1;

Then the combobox view is empty.

I don't understand that I have to do 2 things. What can be wrong here?
Because selectedvalue is filled up? But that is normal?

Thanks for help.
Jac


"Jac" wrote:

Hey,

How can I set the display value of a combobox empty? But all the posible
choices are available when I push the trianglebut.

Sometimes if I set the selecteditem = null it works, other times it don't
work and sometimes I receive an error 'Additional information: Value cannot
be null'.

this.CmbDataSource = SoortKwijtingList.Items; // Arraylist
this.Cmb.DisplayMember = "Omschrijving";
this.Cmb.ValueMember = "Id";
this.Cmb.SelectedItem = null;

I don't understand that, what is so unstable? Has it something to do with
the moment of databinding?

Thanks in advance
jac

Nov 17 '05 #3

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

Similar topics

8
by: Supa Hoopsa | last post by:
I have a databound combobox within a datagrid. I have set the DisplayMember and ValueMember. BUT, how do I capture the Value (SelectedValue) when the user changes the selection?
2
by: amber | last post by:
Hello, I have a combobox populated by a dataset filled with data from a SQL view. In the view I have combined two fields to create one. I can't set my combobox.selectedvalue to this value. Any...
2
by: Deli | last post by:
Hi, I need to check if combobox is empty, so I write: if combobox = null then msgbox "..." but it doesn't work. In debug mode, combobox is null. Please help! Deli
1
by: chen qi | last post by:
## i have a table like this: myID myName ------------------------ ----------------------------- 1 aaa 2 bbb 3 ...
0
by: Gary Boulter | last post by:
hi, I have an object populated from the database, The object has three properties, the ID, a description, and a State If I bind the object as a collection to a combo comboBox.DataSourse =...
6
by: Mike Caputo | last post by:
Shouldn't I be able to set the selected item of a combobox with the SelectedValue property? The ComboBox has four items, the values are 1 through 4. Here's an example of what I'm trying to do: ...
1
by: =?Utf-8?B?RXRoYW4gU3RyYXVzcw==?= | last post by:
Hi, I generally work on web apps, but I am dealing with a Winform right now and may be missing something really basic. I have a combobox and I would like to know what value has been selected....
11
Frinavale
by: Frinavale | last post by:
This question is going to sound a little crazy but.........How do you set the selected item in a ComboBox? I am populating a ComboBox with a bunch of instances of a custom private class: For...
1
by: sanndeb | last post by:
I have a combobox like <ComboBox Height="23" HorizontalAlignment="Left" Margin="88,13,0,0" Name="cmbYears" VerticalAlignment="Top" Width="112" SelectionChanged="cmbYears_SelectionChanged"...
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
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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.