Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Data Binding / October 2006

Tip: Looking for answers? Try searching our database.

ComboBox - Losing binding

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
s26f84@gmail.com - 24 Oct 2006 22:59 GMT
Hey Guys&Gals

my combo box is never empty it always have the text from the first
member of the table... Plz help

my code:

  this.cbo.DataSource = SearchData.Tables["Name"];
  this.cbo.ValueMember = "ID";
  this.cbo.DisplayMember = "Name";
  this.cbo.SelectedIndex = -1;
  this.cbo.Text = " ";





Sunny
Bart Mermuys - 26 Oct 2006 21:25 GMT
Hi,

> Hey Guys&Gals
>
[quoted text clipped - 8 lines]
>   this.cbo.SelectedIndex = -1;
>   this.cbo.Text = " ";

Once you set a DataSource to the ComboBox, then it's backed by a
CurrencyManager which keeps track of position.   A CurrencyManager can't go
to -1 when the list isn't empty, that's what causing the problem.

In NET1.1, you can still force the ComboBox to select -1 if you call
SelectedIndex = -1 twice.

In NET2.0, it can be enough to set it once if ComboBox.FormattingEnabled is
true.

Both will only work at Form_Load (not form constructor).

HTH,
Greetings

> Sunny

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.