有combox控件,命名為cbxPutStatus,在程序中為其手工定義數據源,並綁定
private void POrderSplitFrm_Load(object sender, EventArgs e)
{
//綁定定單狀態
this.cbxPutStatus.DataSource = DataTableForPutStatus();
this.cbxPutStatus.DisplayMember = "PutStatusString";
this.cbxPutStatus.ValueMember = "POrderApproveStatus";
this.cbxPutStatus.SelectedIndex = 0
}
private DataTable DataTableForPutStatus()
{
DataTable dt = new DataTable();
dt.Columns.Add("PutStatusString");
dt.Columns.Add("POrderApproveStatus");
//定義定單狀態 0:未發布;1:已發布;2:所有狀態
dt.LoadDataRow(new object[] { "待發布", "0" }, true);
dt.LoadDataRow(new object[] { "已發布", "1" }, true);
dt.LoadDataRow(new object[] { "所有狀態", "2" }, true);
return dt;
}