someForm.designer.cs
private Infragistics.Win.UltraWinGrid.UltraCombo cmb;
cmb.DisplayMember = "valueColumn";
cmb.ValueMember = "IDColumn";
someForm.cs
SomeDS.SomeDTDataTable temp = new SomeDS.SomeDTDataTable();
this.cmb.DataSource = temp;
this.cmb.DataBind();
this.dataGrid.DisplayLayout.Bands[0].Columns["someColumn"].EditorControl = this.cmb;
SomeDS.SomeDTDataTable
有多个列,现在每个cmb
,而不是仅显示valueColumn
,它会显示所有列?我可以知道哪个部分可能出错了吗?
答案 0 :(得分:1)
这是预期的行为。 UltraCombo创建与您指定为DataSource的DataTable匹配的Layout。要隐藏除了valueColumn之外的所有列,您可以处理组合的InitializeLayout,并将Hidden设置为所有其他列为true,如下所示:
this.cmb.InitializeLayout += Cmb_InitializeLayout;
private void Cmb_InitializeLayout(object sender, InitializeLayoutEventArgs e)
{
foreach(var col in e.Layout.Bands[0].Columns)
{
if(col.Header.Caption != "valueColumn")
{
col.Hidden = true;
}
}
}
答案 1 :(得分:0)
public void AssignDropDown(DataTable dt) { //仅在UltraCombo中显示DisplayMember
string[] fields = new string[]{ dt.Columns[0].ToString() };
ugReqLine.DisplayMember = dt.Columns[0].ToString();
ugReqLine.DataSource = dt;
ugReqLine.ValueMember = dt.Columns[1].ToString();
ugReqLine.SetColumnFilter(fields);
}