Smobiler上海石磨_.NET移动开发平台
标题:
poplist筛选分类
[打印本页]
作者:
Lincy.Lin
时间:
2016-9-28 19:53
标题:
poplist筛选分类
1.拖拉一个poplist和button控件到窗体,代码如下:
/// <summary>
/// poplist新增筛选分类
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnpop_Click(object sender, EventArgs e)
{
DataTable gtable = new DataTable();
gtable.Columns.Add("Type", typeof(String));
int A = 65;
for (int i = 0; i < 26; i++)
{
gtable.Rows.Add((char)(A + i));
}
foreach (DataRow Grow in gtable.Rows)
{
PopListGroup poli = new PopListGroup();
popList1.Groups.Add(poli);
poli.Text = Grow["Type"].ToString();
//设置了此属性,那么在右边会出现一个滚动条,用于筛选,最长支持两个字符。
poli.IndexerKey = Grow["Type"].ToString();
string strConn = "Server=.; database=demo; uid=sa; pwd=123;";
string strSql = "select userID,userName from tblUser where Type='" + Grow["Type"].ToString() + "' ";
System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(strSql, strConn);
DataTable dt = new DataTable();
da.Fill(dt);
foreach (DataRow rowli in dt.Rows)
{
poli.Items.Add(rowli["userName"].ToString(), rowli["userID"].ToString());
}
}
popList1.Show();
}
复制代码
2.客户端显示效果,如图:
[attach]869[/attach]
欢迎光临 Smobiler上海石磨_.NET移动开发平台 (https://www.smobiler.com/)
Powered by Discuz! X3.2