关于Combox简单赋值的问题
/// <summary>
/// 根据数据类型 返回加载后的ComboBox
/// </summary>
/// <param name="type">分为字符型T 数字型N 时间型D 是否型B</param>
/// <returns></returns>
private ComboBox GetOperateCombox(string type)
{
try
{
if (dtOperate == null)
{
dtOperate = Qport.Framework.DBAccess.DataAccess.Instance(QportGlobalParam.strStatDB).SelectDataTable("select * from stat_operate_define");
}
ComboBox cb = new ComboBox();
cb.DropDownStyle = ComboBoxStyle.DropDownList;
cb.DisplayMember = "operate_disp_name";
cb.ValueMember = "operate_start_code";
string strType;
if (type == "N")
{
strType = "num";
}
else if (type == "D")
{
strType = "datetime";
}
else if (type == "B")
{
strType = "bool";
}
else
{
strType = "str";
}
DataRow[] dr = dtOperate.Select("field_type='" + strType + "'");
//foreach (DataRow item in dr)
//{
// cb.Items.Add(item);
//}
//cb.DataSoure = dr;
return cb;
}
catch (Exception ex)
{
Qport.Framework.LogHandle.QportLogger.Instance().LogException(ex);
return null;
}
}
/// <summary>
/// 根据数据类型 返回加载后的ComboBox
/// </summary>
/// <param name="type">分为字符型T 数字型N 时间型D 是否型B</param>
/// <returns></returns>
private ComboBox GetOperateCombox(string type)
{
try
{
if (dtOperate == null)
{
dtOperate = Qport.Framework.DBAccess.DataAccess.Instance(QportGlobalParam.strStatDB).SelectDataTable("select * from stat_operate_define");
}
ComboBox cb = new ComboBox();
cb.DropDownStyle = ComboBoxStyle.DropDownList;
cb.DisplayMember = "operate_disp_name";
cb.ValueMember = "operate_start_code";
string strType;
if (type == "N")
{
strType = "num";
}
else if (type == "D")
{
strType = "datetime";
}
else if (type == "B")
{
strType = "bool";
}
else
{
strType = "str";
}
DataView dvOperate = new DataView(dtOperate);
dvOperate.RowFilter = "field_type='" + strType + "'";
cb.DataSource=dvOperate;
return cb;
}
catch (Exception ex)
{
Qport.Framework.LogHandle.QportLogger.Instance().LogException(ex);
return null;
}
}