Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 20th, 2008, 05:52 AM
Authorized User
 
Join Date: Oct 2006
Location: Kolkata, West Bengal, India.
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default Add Item in a Binded Combo Box

Hello Frnds,
            I am currently woking on windows form programming(C#).I am having a combo box which has a binded dataset.Now my problem is, I want to add a "--Select--" option at index 0 of combo box.How to do it?

Please please help me.



Reply With Quote
  #2 (permalink)  
Old April 20th, 2008, 12:22 PM
Friend of Wrox
 
Join Date: Mar 2007
Location: Hampshire, United Kingdom.
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

I dont think you can do this if the data is bound to a DataSet, I think you would need to load the items for the list and then manually add them to the list, obviously adding the "select" item first.

Rob
http://robzyc.spaces.live.com
Reply With Quote
  #3 (permalink)  
Old April 21st, 2008, 08:45 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I'm not positive that this will work in a windows forms app, but here's how we do it in ASP.NET:

myControl.DataSource = myDataSet;
myControl.DataBind(); // <-- This isn't required in win forms.
myControl.Items.InsertAt(0, "-- Select --");

You should be able to do something similar in a winforms combo box.

-Peter
peterlanoie.blog
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo box to display items from parent combo box Gini Visual Studio 2008 0 June 18th, 2008 12:30 AM
pre-selecting an item in a combo box kscase Visual Basic 2005 Basics 1 July 12th, 2007 07:33 AM
add drop down / combo box for selection mamuco Classic ASP Components 0 May 30th, 2007 06:34 PM
Combo Box item from SQLDataadpter... to Datagrid venkikrao VB.NET 0 April 19th, 2006 08:57 PM
Want Combo Box first item if only 1 item markw707 Access 3 June 9th, 2004 04:03 PM



All times are GMT -4. The time now is 08:15 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.