C# RepositoryItemComboBox为每行添加特定项

C# RepositoryItemComboBox为每行添加特定项,c#,gridview,devexpress,row,gridcontrol,C#,Gridview,Devexpress,Row,Gridcontrol,我在Devexpress GridView上有一个RepositoryItemComboBox控件和4行。RepositoryItemComboBox.Items.Add影响所有行。在CustomRowCellEdit和CustomRowCellEditForEditing事件中,我使用RepositoryItemComboBox.Items.Clear()和RepositoryItemComboBox.Items.Add,但它同样会影响所有行。我需要修改特定的RepositoryItemCom

我在Devexpress GridView上有一个RepositoryItemComboBox控件和4行。RepositoryItemComboBox.Items.Add影响所有行。在CustomRowCellEdit和CustomRowCellEditForEditing事件中,我使用RepositoryItemComboBox.Items.Clear()和RepositoryItemComboBox.Items.Add,但它同样会影响所有行。我需要修改特定的RepositoryItemComboBox。例如,在RepositoryItemComboBox的第一行中应包含“Michael,John”,在RepositoryItemComboBox的第二行中应包含“Sarah,Jake”。

您可以创建一个存储库,并通过处理

然后

    private RepositoryItemComboBox myRepository(string[] myNames)
    {
        RepositoryItemComboBox repositoryItemCombo = new RepositoryItemComboBox();
        repositoryItemCombo.Items.AddRange(myNames);

        return repositoryItemCombo;
    }
    private void GridView1_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e)
    {
        if (e.Column.FieldName != "YourFieldName")
            return;

        if (e.RowHandle == 1) // Your condition
        {
            e.RepositoryItem = myRepository(new string[] { "Michael", "John" });
        }
        else
        {
            e.RepositoryItem = myRepository(new string[] { "Sarah", "Jake" });
        }
    }