Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
5434 | Jul 2,2003 01:44 PM UTC | Jul 3,2003 05:53 PM UTC | WinForms | 7 |
![]() |
Tags: GridControl |
//fill the Data in teh Related Tables
this.adptInput.Fill(this.dsInputList, "Input");
this.adptReel.Fill(this.dsInputList, "tblReel");
//
//add the relation between the tables
//
dsInputList.Relations.Add(
dsInputList.Tables[0].Columns["iID"],
dsInputList.Tables[1].Columns["rInputID"]);
dsInputList.Relations[0].RelationName = "Reels_Relation";
//
//Set the GridHierarchyLevel in order to obtain the "+" link
//
GridHierarchyLevel hlInput = gridBinder.RootHierarchyLevel;
GridHierarchyLevel hlInput_Reels = gridBinder.AddRelation("Reels_Relation");
Now what I need to do is to be able to delate (remove the rows from the Grid). I have created a Handler for the "Delete" key. Deleting from the main table works perfect. But when I try to delete rows from the related Table, I get the following error:
An unhandled exception of type 'System.IndexOutOfRangeException' occurred in system.data.dll
Additional information: There is no row at position 4.
Here is the code that I use for the "Delete" key down event:
private void dgInput_CurrentCellKeyDown(object sender, KeyEventArgs e)
{
if(e.KeyCode == Keys.Delete)
{
GridRangeInfo range = this.dgInput.Selections.Ranges.ActiveRange;
if(range.IsRows)
{
this.dgInput.Binder.EnableRemove = true;
this.dgInput.Binder.RemoveRecords(range.Top, range.Bottom);
e.Handled = true;
}
}
}
Please help.
XP This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.