【问题标题】:How can I delete a row by index in an Infragistics UltraGrid control for Winforms?如何在 Winforms 的 Infragistics UltraGrid 控件中按索引删除行?
【发布时间】:2011-07-29 13:07:14
【问题描述】:

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

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

有什么建议吗?

【问题讨论】:

    标签: c# winforms infragistics ultrawingrid


    【解决方案1】:

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

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

    艾伦

    【讨论】:

      【解决方案2】:

      我找到了这个示例代码;

      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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2010-10-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多