我的组合框中包含了我数据库中所有表的列表:
using(DataContext db = new DataContext())
{
cmbbx_tables.DataSource = db.Mapping.GetTables().Select(q=>new {q.TableName, q.RowType}).ToArray();
cmbbx_tables.DisplayMember = "TableName";
cmbbx_tables.ValueMember = "RowType";
}
在SelectionChangeCommitted
事件中,我想获取所选表的名称:
private void cmbbx_tables_SelectionChangeCommitted(object sender, EventArgs e)
{
using(DataContext db = new DataContext())
{
String table = db.Mapping.GetTable((???)cmbbx_tables.SelectedValue).TableName;
}
}
我应该如何输入cast cmbbx_tables.SelectedValue?
答案 0 :(得分:0)
解决方案是:
String name = db.Mapping.GetTable((cmbbx_tables.SelectedValue as System.Data.Linq.Mapping.MetaType).Type).TableName;