我可能是一個小問題,但無法找到解決辦法......C#組合框的結合和第一空值
我有一個WinForm一個組合框,而此組合框已經綁定到一個數據表中的列。 此列(保留打印機名稱)允許爲空值。我希望組合框顯示第一個值字符串「default」,然後顯示打印機列表。但我不希望「默認」字符串存儲在數據表中,只是空。
cmbDefaultPrinter.DataSource = this.availablePrinters;
cmbDefaultPrinter.DisplayMember = "Display";
cmbDefaultPrinter.ValueMember = "Value";
cmbDefaultPrinter.DataBindings.Add(new Binding("Text", ctr.ds.Tables[t.toTable], "printer"));
其中availablePrinters是這個類的列表:在availablePrinters
class myPrinters
{
public string Value { get; set; }
public string Display { get; set; }
public myPrinters(string value, string display)
{
this.Value = value;
this.Display = display;
}
}
和第一個元素是:myPrinter(NULL, 「默認打印機」);
我在做什麼錯?
當你運行它會發生什麼? – recursive 2011-02-08 15:30:56
作爲打印機的值,當選擇「default」時,空字符串將存儲insead的空值... – Ray 2011-02-08 15:42:14