OK、.NET のデータ バインディングでかなりの問題が発生しています。
背景情報として、私のビジネス オブジェクト層は CSLA v1.0 を使用しています。
そして _clientObj は、CSLA.BusinessBase を継承するビジネス オブジェクトとしてパラメーターとして渡されます。
コード セグメントは次のとおりです。
Dim nextClient As New ComboBox With { _
.Name = "txtClientAtt" & (ClientBoxes.Count + 1).ToString(), _
.DisplayMember = "FullNameAndID", .ValueMember = "ClientID", _
.Tag = _clientObj}
nextClient.DataSource = ClientList.GetClientList(SelectedSite)
nextClient.DataBindings.Add("SelectedValue", _clientObj, "ClientID")
If Not _clientObj.ClientID = Nothing AndAlso nextClient.SelectedValue Is Nothing Then
Debug.Print("How could I ever be inside this conditional????")
End If
_clientObj が ID 値が割り当てられた既存のオブジェクトである場合、実際にそのデバッグ ステートメントに到達します。そんなことがあるものか?DataSource オブジェクトに初期値がある場合、データ バインディングを追加すると、ComboBox の .SelectedValue プロパティがすぐに設定されると想定していました。