Windows client tidbits
I have been writing a rich client and I came across some interesting behaviour. If you are binding a control to a data source be careful about the order in which you bind the control.
Initially I used the following code :
cboDay.DataSource =myTimesheet.Tables["date"]; cboDay.DisplayMember="day";
However, there is a problem with this code if you happen to validate data which is typed into cboDay as the textchanged event will be fired as soon as you set the data source but the control will not contain the expected value until you set the datasource. In order to avoid this problem always set the display member and, if required, the value member prior to setting the data source.
In other words always use this sequence of commands :
cboDay.DisplayMember="day"; cboDay.DataSource =myTimesheet.Tables["date"];
[Martin Spedding]
6:48:12 PM
|