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

Home Posts Topics Members FAQ

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.CmbDataSou rce = SoortKwijtingLi st.Items; // Arraylist
this.Cmb.Displa yMember = "Omschrijvi ng";
this.Cmb.ValueM ember = "Id";
this.Cmb.Select edItem = 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 43466
Hi Jac,

Set ComboBox.Select edIndex = -1;
On Thu, 28 Apr 2005 22:34:18 +0200, Jac <Ja*@discussion s.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.CmbDataSou rce = SoortKwijtingLi st.Items; // Arraylist
this.Cmb.Displa yMember = "Omschrijvi ng";
this.Cmb.ValueM ember = "Id";
this.Cmb.Select edItem = 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.Soort Kwijting == null )
this.Cmb.Select edIndex = -1;
else
this.Cmb.Select edValue = kwijting.SoortK wijting.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.Select edIndex = -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.Select edIndex = -1;
this.Cmb.Select edValue= -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.CmbDataSou rce = SoortKwijtingLi st.Items; // Arraylist
this.Cmb.Displa yMember = "Omschrijvi ng";
this.Cmb.ValueM ember = "Id";
this.Cmb.Select edItem = 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
2874
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
380
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 other field in the view works, but this one leaves the combobox empty... The purpose behind this is to display what the user is to select, along with a description of each item.
2
3254
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
4069
by: chen qi | last post by:
## i have a table like this: myID myName ------------------------ ----------------------------- 1 aaa 2 bbb 3 ccc ## in VS2003, i write code: //
0
1273
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 = <objectcollection> comboBox.DisplayMember = "description" comboBox.ValueMember = "ID"
6
40898
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: Sub SetLevel(Level as Short) cboLevel.SelectedValue = Level End Sub I try this assignment, and the SelectedValue property remains Nothing. I know for sure that the Level variable is within the 1 - 4 range, and no
1
7254
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. When I try to get the value as a string I sometimes get errors because Combobox.SelectedValue is a DataRowView and when I try to get the value by first casting as a DataRowView I sometimes get errors because I can't cast a string to a DataRowView! I...
11
3315
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 Each s as Something In MyListOfSomethings MyComboBox.Items.Add(New XYZListItem(s.ID,s.description)) Next MyComboBox.ValueMember = "ID" MyComboBox.DisplayMember = "Description"
1
24533
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" Canvas.Left="13" Canvas.Top="0"> <ComboBox.Items> <ComboBoxItem Tag="2010" Content="2010" /> <ComboBoxItem Tag="2011" Content="2011" /> <ComboBoxItem Tag="2012" Content="2012" /> <ComboBoxItem Tag="2013" Content="2013" /> <ComboBoxItem...
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...
1
8897
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
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...
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.