开发者

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

I have a Windows Forms and inside I have an UltraGrid component.

I'd like to delete开发者_开发知识库 a row by using it's numerical index, how can I achieve this? The documentation for Infragistics is extremely lacking and I can't seem to find relevant information.

Any suggestions?


I would recommend removing the item from the list that the WinGrid is bound to and this would remove it from the grid. If you know the index of the item in the list, then you could remove it from your list using the RemoveAt method.

If you have a reference to the UltraGridRow object that you wish to remove, then you could use the Remove method passing in the ListObject property of the UltraGridRow to the Remove method of your list.

Alan


I found this sample code;

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
    }

}

Also take a look these articles

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜