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; } }
}
}
茶杯头甜蜜终章dlc 官方手机版v1.0.0.3
下载火柴人传说暗影格斗内置菜单 最新版v3.0.1
下载荒野乱斗测试服 安卓版v61.10.3
下载荒野乱斗彩虹服 安卓版v61.10.3
下载寒霜启示录 安卓版v1.25.10
寒霜启示录是一款生存模拟游戏,不少玩家可能对于末日都有着自己
末日城堡免广告版 安卓最新版v0.7.1
末日城堡免广告版是一款非常好玩的模拟经营类游戏,内部可以不看
甜蜜人生模拟器 最新版v1.4.5
甜蜜人生模拟器是一款非常好玩的模拟恋爱手游,玩家在这里能够对
武器锻造师内置功能菜单 v10.4
武器锻造师内置菜单版是游戏的破解版本,在该版本中为玩家提供了
开放空间overfield 安卓版v1.0.5
开放空间Overfield是一款箱庭养成经营手游,让你在广阔