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
,而是显示所有列?我能知道哪一部分可能出了问题吗?
这是预期行为。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;
}
}
}
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);
}