Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Taking combobox items from list instead of business obje
Message
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
01003325
Message ID:
01003945
Vues:
16
This message has been marked as the solution to the initial question of the thread.
Andrew,

>How would you make the mmCombobox get its values from the list instead of a lookup business object?

What kind of list are you talking about?

You can use the AddRange method of the combo box like this:

this.lstDemos.Items.AddRange(new string[] {
"DataSet Performance",
"DataSet Serialization",
"Provider Factories",
"Database Enumerator",
"Bulk Copy",
"Provider Statistics",
"Multiple Active Result Sets (MARS)",
"Get One Million Records"});

>If this is not possible then how do you make a 'fake' business object (business object that is not based on a table) that contains the values that I want to show in the mmCombobox's items?

You can manufacture a DataTable out of "thin air" without retreiving data from the back end. For example, you could put the following code within a method of your business object:
// Create a new DataSet
DataSet ds = this.CreateDataSet();

// Create a new DataTable
ds.Tables.Add("MyTable");
ds.Tables[0].Columns.Add("UniqueID", typeof(Int32));
ds.Tables[0].Columns["UniqueID"].Unique = true;
ds.Tables[0].Columns.Add("TextValue", typeof(String));

// Create a DataRow and add it to the DataTable
DataRow dr = ds.Tables[0].NewRow();
dr["UniqueID"] = 1;
dr["TextValue"] = "My Text Value";
ds.Tables[0].Rows.Add(dr);

// Set the DataSet as the business object's current DataSet
this.SetCurrentDataSet(ds);
In order to get your list to bind to this DataTable, the name of the table must be the same as the business object's "TableName" property, or you can specify in the binding properties the name of the DataTable you have manufactured. For more information, check out the MM .NET Dev Guide topic "Data Binding Windows Forms List Controls".

Regards,
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform