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

发布于 2024-11-26 18:01:02 字数 124 浏览 1 评论 0原文

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

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

有什么建议吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你怎么敢 2024-12-03 18:01:02

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

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

艾伦

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

罗罗贝儿 2024-12-03 18:01:02

我找到了这个示例代码;

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

<一个href="http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=7384" rel="nofollow">http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=7384

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文