I am trying to do drag and drop within the same grid. I have a hierarchical DataSet so my grid has several Bands. When I move rows within the same band everything is working fine. But if I want to move row from one band to another - it is not working and row remains at the same place. Actually I think it is trying to drop withing a band causerow sometime moves withing the band.
I am using the following code:
private void ultraGrid1_InitializeLayout(object sender, InitializeLayoutEventArgs e)
ultraGrid1.AllowDrop = true; e.Layout.Override.SelectTypeRow = SelectType.ExtendedAutoDrag; e.Layout.Override.RowSelectors = Infragistics.Win.DefaultableBoolean.True; e.Layout.Override.CellClickAction = CellClickAction.RowSelect;
private void ultraGrid1_DragDrop(object sender, DragEventArgs e)
aRow.ParentCollection.Move(aRow, dropIndex); // cause I am not moving upper level rows
The Move method just re-orders the rows in the same collection. It has no effect on the underlying data source.
Moving a row to a different band would require you to modify the data source.
I am modifying DataSourse. My DataSource is like this:
_ReportSeries = new DataSet(); _ReportSeries.Tables.Add(VWA4Common.DB.Retrieve("SELECT * FROM ReportSeries WHERE SiteID = " + siteID)); _ReportSeries.Tables[0].TableName = "ReportSeries"; _ReportSeries.Tables.Add(VWA4Common.DB.Retrieve("SELECT * FROM ReportSeries LEFT JOIN " + " (ReportSet LEFT JOIN ReportMemorized ON ReportSet.ReportMemorized = ReportMemorized.ID ) " + " ON ReportSet.SerieID = ReportSeries.ID WHERE ReportSeries.SiteID = " + siteID + " ORDER BY [Order]")); _ReportSeries.Tables[1].TableName = "ReportSet"; _ReportSeries.Relations.Add(new DataRelation("ReportSet", _ReportSeries.Tables["ReportSeries"].Columns["ID"], _ReportSeries.Tables["ReportSet"].Columns["SerieID"]));
So subtable connected to main Table via SerieID. So in private void ultraGrid1_DragDrop(object sender, DragEventArgs e) I modify thisSerieID like this:
foreach (UltraGridRow aRow in SelRows){ DataRow dataRow = ((DataRowView)aRow.ListObject).Row; dataRow["ReportSeries.ID"] = ugrOver.Cells["ID"].Value; dataRow["SerieName"] = ugrOver.Cells["SerieName"].Value; dataRow["SiteID"] = ugrOver.Cells["SiteID"].Value;
aRow.ParentCollection.Move(aRow, dropIndex);
}
ultraGrid1.Refresh();
But row remains in the same place. How to force relation to change?
Mila.