0

我有一个 Windows 窗体,里面有一个 UltraGrid 组件。

我想通过使用它的数字索引来删除一行,我该如何实现呢?Infragistics 的文档非常缺乏,我似乎无法找到相关信息。

有什么建议么?

4

2 回答 2

2

我建议从 WinGrid 绑定到的列表中删除该项目,这会将其从网格中删除。如果您知道列表中项目的索引,则可以使用 RemoveAt 方法将其从列表中删除。

如果您有对要删除的 UltraGridRow 对象的引用,则可以使用将 UltraGridRow 的 ListObject 属性传递给列表的 Remove 方法的 Remove 方法。

艾伦

于 2011-07-29T13:39:26.907 回答
1

我找到了这个示例代码;

protected void wgSubstancesUsed_UpdateRow(object sender, Infragistics.WebUI.UltraWebGrid.RowEventArgs e)
{
    switch (e.Row.DataChanged)
    {
        case Infragistics.WebUI.UltraWebGrid.DataChanged.Added:
            this.InsertRecord(e.Row);
            break;

        case Infragistics.WebUI.UltraWebGrid.DataChanged.Modified:
            this.UpdateRecord(e.Row);
            break;

        case Infragistics.WebUI.UltraWebGrid.DataChanged.Deleted:
            this.DeleteRecord(e.Row);
            break;

    }

}

private void DeleteRecord(UltraGridRow theGridRow)
{
    //Get the GUID of the record you wish to delete from the grid (for me
    //  the first hidden field of the grid
    Guid thePrimaryKey = new Guid(theGridRow.Cells[0].Value.ToString());
    if (thePrimaryKey != null)
    {
        busClientObject oClient = new busClientObject()
 oClient.Load(thePrimaryKey);  //Get to the individual record, load it into the object
        oClient.DataRow.Delete();  //Mark that record for deletion
        oClient.Save();    //Actually delete it
    }

}

也看看这些文章

http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=7384

http://forums.infragistics.com/forums/p/24697/90536.aspx

http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=7384

于 2011-07-29T13:15:40.607 回答