Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Bound controls
Message
De
07/07/2004 18:19:25
 
 
À
07/07/2004 17:35:51
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Titre:
Divers
Thread ID:
00921632
Message ID:
00921696
Vues:
16
Bonnie,

In the class definition:
public string formProperty;
public string FormProperty
   {
      get { return formProperty; }
      set { formProperty = value; }
   }
In the forms constructor:
InitializeComponent();
FormProperty = "hello world";
txtBoundFormProperty.DataBindings.Add("Text" , this,
		FormProperty);
Getting an exception: Cannot bind to property or column hello world on DataSource.
Parameter name: dataMember. I've also tried to issue formProperty as the last parameter to DataBindings.Add(). Tried to make formProperty private, same result.

Thanks,
steve


>Yep, you can bind to a property ... but make sure it's a public *property* (with a get/set) and not simply a field (public or otherwise).
>
>MyTextBox.DataBindings.Add("Text", this, "MyProperty");
>
>
>~~Bonnie
>
>
>>Learning how to bind controls to objects is giving me fits. It seems that you can only bind a control to an Array (or other collection using the IList interface), or a DataSet (and DataTable, I suppose).
>>
>>What if I want to bind textBox.text to a property of a form, or a member of some other class. Can that be done?
>>
>>Thanks again,
Steve Gibson
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform