473,379 Members | 1,184 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,379 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 43418
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"...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...

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.