Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
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 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 March 17th, 2006, 05:06 AM
Registered User
 
Join Date: Jan 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with ComboBox - Extremely urgent

Hi.

I'm getting the strangest error, and it's frustrating me to no end.
This is extremely urgent as I HAVE to have everything working before the end of this day.

Problem:

When I try and populate a combobox, I get the error "Cannot find Table 0".

Firstly I attempted to set the combobox's Datasource property to an ArrayList (The ArrayList checks out, nothing wrong there.)
I got above mentioned error.
After that, I decided to loop through the arraylist and add each item
basically . cmbBox.Items.Add(alList[iX].ToString())
What happened then is that the combobox Text property was empty.
So naturally I added a line which set the text property to the first item in the combobox's item list. (Yes as text)
Same error occurs.

I can only think that is one of microsoft's endless list of screwups. The fact remains that I cannot show our prototype with an error popping up.

Please please please help me. How does one fix this?
Is there perhaps a way to switch that error off?

Any help would be of great value to me.

Thank you.


 
Old March 17th, 2006, 08:46 AM
Registered User
 
Join Date: Jan 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Anybody?? :(

 
Old March 17th, 2006, 11:02 AM
Authorized User
 
Join Date: Mar 2006
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

When you are using the cmbBox.Items.Add(alList[iX].ToString()) approach, are you sure that you removed the DataSource property. Moreover, have u set the DataSource property of the combobox to something in the designer?

Pls post the section of code where you populate the combobox items.

If you program works well despite the error, then to "turn the error off", try placing the code in a try-catch block and not doing anything if you "catch".

HTH

Sreeram
 
Old April 5th, 2006, 06:00 AM
Registered User
 
Join Date: Apr 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

we encountered the same problem and this is how we managed to populate correctly the combobox.

Imagine you have a class named Dog_Race

The class contain some arguments
public string race_name
public int race_id
Your constructor looks like that
public Dog_Race()
{

}
You have to create another constructor

public Dog_Race(int idrace, string namerace)
{
    this.race_name=namerace;
    this.race_id = idrace;

}

Now, you have to create getter and setter
public int getIdRace()
{
   return(this.race_id);
}
public string getNameRace()
{
   return(this.race_name);
}
public override string ToString()
{
   return this.getNameRace();
}


That's for the Dog_Race class
Now, how to populate the combobox using it :

//for example
MyCombobox.items.add(new Dog_Race(0,'MyRaceName'));

And, how to get the values from Combobox
int dograceid = ((Dog_Race)MyCombobox.selectedItem).getIdRace();
int dogracename = ((Dog_Race)MyCombobox.selectedItem).getNameRace();


Hope it'll help you







Similar Threads
Thread Thread Starter Forum Replies Last Post
SQLDataReader - Extremely poor performance Miraval ADO.NET 1 October 2nd, 2007 12:12 PM
Extremely annoying VS.Net behavior katsarosj VS.NET 2002/2003 6 April 17th, 2006 09:21 AM
Embed ListView in Combobox (Urgent) HemaChaudhry VB.NET 0 January 2nd, 2006 09:17 AM
ComboBox problem chacquard Access 2 September 10th, 2004 11:40 AM
Too long cleanup.asp for extremely big reports darkov Crystal Reports 0 March 8th, 2004 07:03 AM





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