Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to clear a combobox?
Message
De
07/05/2004 19:01:42
 
 
À
07/05/2004 14:51:01
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Divers
Thread ID:
00898211
Message ID:
00902125
Vues:
45
Lee,

Don't you just love it when you finally have that "ah hah!" moment? <s>

>How does it know what record in the .DataBindings datasource to "attach" to?

That all depends on the row you're "on" in the table, which is determined by the BindingContext's .Position property. (I see more questions coming ... <g>)

~~Bonnie



>Bonnie,
>
>Argh!! Where are my shade?!?! The light just came on so bright I'm almost blind! LOL! :)
>
>I get it now. I've just been using ComboBox's to let the user select something and I performed an action on that selection. So the DataSource, DisplayMember, and ValueMember properties attach specific properties of the ComboBox to a datasource for data to flow from the datasource to the ComboBox. The .DataBindings property used to attach properties on the ComboBox to a datasource for data to flow from the ComboBox to the datasource. I'll have to look into that. How does it know what record in the .DataBindings datasource to "attach" to?
>
>-----
>Lee Perkins
>
>>Lee,
>>
>>> ComboBox.SelectedText has the data from the DisplayMember field and ComboBox.SelectedValue has the associated data from the ValueMember field
>>
>>Yep, that's what happens. But that only does you any good if you then *do* something with those. That's where DataBinding comes in.
>>
>>Does .DataBindings do something in addition to this? I'm confused on what exactly .DataBindings do
>>
>>Say you have a form where you edit data from a table. One column in your table can be one of several different codes. Here's where you would use a Combo to represent that column in your table. The Combo's DataSource would be a different table (a code table) containing all the possible codes for that particular column in your main table. When you choose an item from that Combo, it won't automatically get saved to the column in your main table unless you DataBind it. If you don't DataBind it, you would have to manually set the value of the column in your main table (in either the Combo's SelectedValueChanged, SelectedIndexChanged or Validated event handlers). By DataBinding to the column, it's all done automatically ... which is obviously the preferred way of doing things.
>>
>>~~Bonnie
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform