using system;
using system.collections.generic;
using system.componentmodel;
using system.data;
using system.drawing;
using system.text;
using system.windows.forms;namespace winformcombobox
{
public partial class frmmain : form
{
public frmmain()
{
initializecomponent();
}
#region members
arealists ac;
public arealists gettestarea()
{
arealists al = new arealists();
for (int i = 1; i < 11; i++)
{
area a = new area();
a.area_id = i.tostring();
a.area_name = "第" + i.tostring() + "名";
al.add(a);
}
return al;
}#endregion
#region events
private void frmmain_load(object sender, eventargs e)
{
ac = gettestarea();
cblist.datasource = ac;
cblist.displaymember = "area_name";
cblist.valuemember = "area_id";
}
private void btnsetcombobox_click(object sender, eventargs e)
{
////setvalue0();
//setvaluebyvalue();
////setvaluebyitem();
setvaluebytext();}
#endregion#region methods
private void setvalue0()
{
area a = new area();
a.area_id = "8";
a.area_name = "第8名";cblist.datasource = gettestarea();
cblist.displaymember = "area_name";
cblist.valuemember = "area_id";
cblist.selectedvalue = a.area_id;
lbresult.text = cblist.selectedvalue.tostring();
}private void setvaluebyvalue()
{
area a = new area();
a.area_id = "8";
a.area_name = "第8名";cblist.selectedvalue = a.area_id;
lbresult.text = cblist.selectedvalue.gettype().tostring() + ":" + cblist.selectedvalue.tostring();
}private void setvaluebyitem()
{
area a = new area();
a.area_id = "8";
a.area_name = "第8名";cblist.selecteditem = ac.findall(delegate(area ar) { return ar.area_id == a.area_id; })[0];
lbresult.text = cblist.selecteditem.gettype().tostring() + ":" + cblist.selectedvalue.tostring();
}private void setvaluebytext()
{
area a = new area();
a.area_id = "8";
a.area_name = "第8名";cblist.selectedindex = cblist.findstring(a.area_name);
lbresult.text = cblist.selectedvalue.gettype().tostring() + ":" + cblist.selectedvalue.tostring();
}
#endregion
}
}
using system;
using system.collections.generic;
using system.text;namespace winformcombobox
{
#region area
public class area
{
private string m_area_id;
public string area_id
{
get { return m_area_id; }
set { m_area_id = value; }
}private string m_area_name;
public string area_name
{
get { return m_area_name; }
set { m_area_name = value; }
}
private double m_area_order;
public double area_order
{
get { return m_area_order; }
set { m_area_order = value; }
}
}
#endregion[serializable]
public class arealists : list
{
private int _maxitems = 0;
public int maxitems { get { return this._maxitems; } set { this._maxitems = value; } }
}
}
敢达决战官方正版 安卓版v6.7.9
下载敢达决战 安卓版v6.7.9
下载像素火影骨架佐助 (Perseverance Fire Shadow)手机版v1.16
下载要塞英雄 安卓版v33.20.0-39082670-Android
下载梦想城镇vivo最新版本 安卓版v12.0.1
梦想城镇vivo版是这款卡通风模拟经营类手游的渠道服版本,玩
怦然心动的瞬间 安卓版v1.0
怦然心动的瞬间是一款真人向的恋爱互动游戏,在游戏中玩家将扮演
曼尼汉堡店游戏 安卓版v1.0.3
曼尼汉堡店是一款非常好玩的精品恐怖类型冒险游戏,在这款游戏中
现代总统模拟器去广告版 安卓版v1.0.46
现代总统模拟器是一款休闲养成类游戏,可能对于不少的玩家来说都
现代总统模拟器付费完整版 安卓版v1.0.46
现代总统模拟器高级版在商店是需要付费的,相对于普通版本,高级