【高分求教熟悉Syncfusion的大侠】如何动态更新一个DataGrid的ComboBox选项
我使用Syncfusion的GridDataBoundGrid在一个WinForm中定义了一个Grid表格,其中的两列为下拉列表类型,我使用下面的函数定义这两列的Foreign Key,以显示关系表中对应ID的名称:
public void setForeignKeyColumn(GridDataBoundGrid grid,string strSelTable,string strColName,string strFName,string strFID)
{
try
{
m_Conn.Open();
OleDbDataAdapter daTemp = new OleDbDataAdapter(strSelTable, m_Conn);
if (m_DS.Tables.Contains(strColName)) m_DS.Tables.Remove(strColName);
daTemp.Fill(m_DS, strColName);
m_Conn.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
GridBoundColumn column = grid.Binder.InternalColumns[strColName];
GridStyleInfo si = column.StyleInfo;
column.MappingName = strFID;
si.CellType = "ComboBox";
si.DataSource = m_DS.Tables[strColName];
si.DisplayMember = strFName;
si.ValueMember = strFID;
si.ShowButtons = GridShowButtons.ShowCurrentRow;
si.HorizontalAlignment = GridHorizontalAlignment.Left;
si.DropDownStyle = GridDropDownStyle.Exclusive;
}
strSel = "SELECT * FROM TBL_System";
setForeignKeyColumn(this.gridControl1, strSel, "SystemID", "SystemName", "SystemID");
我希望这下拉列表的选项是用户能够自行更改的,可是我在用户完成选项编辑后重新调用setForeignKeyColumn函数,并调用了this.gridControl1.Refresh(); 下拉列表的选项并未更新,请教如何能够做到即时更新ComboBox的下拉选项。