簡體   English   中英

如何在用於Winforms的Infragistics UltraGrid控件中按索引刪除行?

[英]How can I delete a row by index in an Infragistics UltraGrid control for Winforms?

我有一個Windows窗體,里面有一個UltraGrid組件。

我想通過使用數字索引刪除一行,如何實現呢? 極其缺乏Infragistics的文檔,我似乎找不到相關信息。

有什么建議么?

我建議從WinGrid綁定列表中刪除該項目,並將其從網格中刪除。 如果知道列表中項目的索引,則可以使用RemoveAt方法將其從列表中刪除。

如果對要刪除的UltraGridRow對象有引用,則可以使用Remove方法,將UltraGridRow的ListObject屬性傳遞給列表的Remove方法。

艾倫

我找到了此示例代碼;

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM