Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Simple data binding to a property
Message
From
13/09/2003 11:39:13
 
 
General information
Forum:
ASP.NET
Category:
Forms
Miscellaneous
Thread ID:
00828163
Message ID:
00828757
Views:
18
Steve (and anyone else following this thread),

I apologize for spitting out answers without actually trying it. Usually I only reply to stuff I know or have already done, and when it's something I haven't done, I'll play with it first before I bother making a fool of myself with a bad answer. However, I was busy and so I didn't take the time to test things, so my answers were a bit vague, weren't they?

It sounds like you've figured it out ok ... even the ComboBox will bind just fine to a property, as long as you're binding to an actual property and not a public field ... I don't know what your problem was though with your ComboBox example ... the stuff I just played with worked fine even if I didn't instantiate the field. IOW:
private int m_Mine;
public int Mine
{
  get {return m_Mine;}
  set {this.m_Mine = value;}
}

this.MyCombo.DataBindings.Add("SelectedValue", this, "Mine");
Note that I never instantiate m_Mine, and yet it compiled fine and ran fine. So, you must've missed something somewhere. Try again? <s>

~~Bonnie


< snip >
>However, for some reason it won't work with a ComboBox:
>
>cboShippers.DataBindings.Add("SelectedValue",this,"CboValue");
>
>
>Where "CboValue" is a public (Int32) property on the form (the ValueMember of the combo is set to an Int32 column). This at least yields a different error, "Object reference not set to an instance of an object".
>
>So what's not an object? this? It most certainly is! CboValue? Well, no it isn't - is it s'posed to be? <s>
>
>Thanks again.
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform