Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 31st, 2007, 10:50 AM
Authorized User
 
Join Date: Oct 2007
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default ComboBox + DropDownList

Hi,

I have a ComboBox set to DropDownList to prevent users from typing in data.

The ComboBox is binded to a dataset.

I want the first option to display automatically on the ComboBox as "Select an Option"

How do I do this?

Thanks.


 
Old October 31st, 2007, 11:11 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

comboBox.Items.Insert(0, "Select an Option");

/- Sam Judson : Wrox Technical Editor -/
 
Old October 31st, 2007, 11:21 AM
Authorized User
 
Join Date: Oct 2007
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by samjudson
 comboBox.Items.Insert(0, "Select an Option");
Get this error...

Items collection cannot be modified when the DataSource property is set
 
Old October 31st, 2007, 11:48 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Ah, right, apologies. In that case you're probably have to resort to adding the value to your datasource.

/- Sam Judson : Wrox Technical Editor -/
 
Old November 30th, 2007, 07:12 AM
Authorized User
 
Join Date: Jul 2006
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I had the same problem a while a go. I resolved it by creating a distinct query on the field i want to populate. And the reslut of that query filled my items Collection. After this procedure ive added the Select an Option Like Samjudson told you.

Greetings MacDevv






Similar Threads
Thread Thread Starter Forum Replies Last Post
combobox nagarajuballa Java GUI 0 August 13th, 2008 03:49 AM
Filling Combobox with value from other Combobox ayazhoda Access VBA 6 June 5th, 2007 04:58 AM
combobox calvados ADO.NET 1 February 8th, 2005 05:37 PM
New to ComboBox adriant42 Excel VBA 3 August 23rd, 2004 12:32 PM
combobox HenkRog VS.NET 2002/2003 2 March 17th, 2004 01:07 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.