|
本帖最后由 tangshun 于 2013-5-21 12:44 编辑
- #region 绑定下拉列表框
- /// <summary>
- /// 绑定下拉列表框
- /// </summary>
- /// <param name="flag">是否显示全部</param>
- /// <param name="ds">DataSet数据集</param>
- /// <param name="cbx">绑定的下拉框名</param>
- public void CboEQUList(bool flag, DataSet ds, ComboBox cbx)
- {
- if (flag == true)
- {
- DataRow dr = ds.Tables[0].NewRow();
- dr["cd"] = "%%";
- dr["nm"] = "全部";
- //dt中添加行并指定添加行在表(dt)中的索引
- ds.Tables[0].Rows.InsertAt(dr, 0);
- }
- //绑定下拉框数据源
- cbx.DisplayMember = "nm";
- cbx.ValueMember = "cd";
- cbx.DataSource = ds.Tables[0];
- //默认显示列
- }
- //---------------------------------------------------------------------------------------------
- //bool=true,false
- //dataet=select nameID as cd ,name as nm from userinfo
- //ComboBox=comboBoxName
- //---------------------------------------------------------------------------------------------
- #endregion
复制代码 |
|