我有一個Windows窗體,裏面有一個UltraGrid組件。如何通過WinForms的Infragistics UltraGrid控件中的索引刪除一行?
我想通過使用它的數字索引刪除一行,我該如何實現? Infragistics的文檔非常缺乏,我似乎無法找到相關信息。
有什麼建議嗎?
我有一個Windows窗體,裏面有一個UltraGrid組件。如何通過WinForms的Infragistics UltraGrid控件中的索引刪除一行?
我想通過使用它的數字索引刪除一行,我該如何實現? Infragistics的文檔非常缺乏,我似乎無法找到相關信息。
有什麼建議嗎?
我發現這個示例代碼;
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
我會建議從列表中刪除該WinGrid綁定到項目,這將將其從網格中刪除。如果您知道列表中項目的索引,則可以使用RemoveAt方法將其從列表中刪除。
如果您有對希望刪除的UltraGridRow對象的引用,那麼可以使用將UltraGridRow的ListObject屬性傳遞給列表的Remove方法的Remove方法。
Alan