0
所以我無法獲得正確的數據顯示在我的子窗體中。需要幫助顯示使用數據綁定的布爾屬性狀態
我正在使用子窗體來列出有關在條目(父)窗體中選擇的當前對象的詳細信息。
我的問題在於我的綁定對象。我有一個布爾屬性(IsAutomatic),並在我想要的細節表單中顯示爲「自動」,當爲「手動」時顯示。
我似乎無法得到一個字符串來顯示我的表單,只有「真」或「假」這個字其實是價值,而不是我想要的。
下面是我用過的代碼。
Binding _transmission = new Binding("Text", _formDataSource.Current, "IsAutomatic");
//how the hell do i do this?
_transmission.FormatString = string.Format(//and i've tried a ternary operator here to display literals depending on if _transission is true or false, but this is a binding object and not a bool data type. I attempted to try a cast on the _transmission object, but the IDE did not like it at all.
lblTransmission.DataBindings.Add(_transmission);
// do i want code the ternary here
(lblTransmission.Text.Equals("true")) ? "Automatic" : "Manual"; //this brought up errors too...
任何幫助將不勝感激,因爲我已經在這一段時間了。