SOLVED: Delete Rows and Childs |
Post Reply |
Author | |
markmark
Senior Member Joined: 30 November 2007 Status: Offline Points: 142 |
Post Options
Thanks(0)
Posted: 24 July 2008 at 3:46am |
Hi it’s me again (I'm Sorry) This time I am trying to delete rows from the report. First I tried: Dim grdReportRow As ReportRow
If grdReportRow.GroupRow = False Then wndReportControl.Records.RemoveAt (grdReportRow.Record.Index) End If Next But if the row is a child the index starts again, and so the deleted row is not the selected row. Then I try Dim grdReportRow As ReportRow
For Each grdReportRow In wndReportControl.SelectedRows If grdReportRow.GroupRow = False Then Call wndReportControl.RemoveRowEx(grdReportRow) End If Next This seems to work except it will crash. See example. In the zip is a Picture with the selection you need to make to cause the crash. All I want is to be able to multi select the rows and delete them. Thanks for your help |
|
Product: Xtreme SuitePro (ActiveX) version 13.0.0
Platform: Windows XP (32bit) - SP 2 Language: Visual Basic 6.0 |
|
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
Hi,
There's something missing in the sample with adding the records. My guess is, that the remove method is working as expected, but some references are missing in record collection or SelectedRows collection.
I suggest you report this to support
|
|
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2 Language: Visual Basic 6.0 Zero replies is not an option.... |
|
Peter59
Groupie Joined: 19 July 2007 Status: Offline Points: 61 |
Post Options
Thanks(0)
|
Hi,
try to delete selected rows backwards: Dim rptRow As XtremeReportControl.ReportRow Dim i As Integer For i = (wndReportControl.SelectedRows.Count - 1) To 0 Step -1 Set rptRow = wndReportControl.SelectedRows.Row(i) Debug.Print "about deleting rowindex "; rptRow.Index wndReportControl.RemoveRowEx rptRow Next i wndReportControl.Populate I could imagine that the cause of the problem is that the internal row collection is reordered every time you delete a row - if you are using and deleting rows with childs. Maybe support can tell us, why deleting selected rows the forward way is crashing. See the modified sample for a working solution. uploads/20080724_034601_deleterows.zip Finally this workaround is better than nothing Don't forget to add "SOLVED" to the topic when your problem is solved. |
|
Product: Xtreme SuitePro (ActiveX) version 15.2.1
Platform: Windows 7 64 Bit Language: Visual Basic 6.0 SP6 |
|
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
Hi Peter,
Doesn't matter how you do this, seems that some references are lost on the way. Look at the image and try to delete the selected records. You will see that only the first selected record will be deleted and strangely enough the record after the second record and it's childs as well. That's why it crashes...
I have a simular problem with the UpdateRecord method, this seems almost to have a reference to the next record.
|
|
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2 Language: Visual Basic 6.0 Zero replies is not an option.... |
|
Peter59
Groupie Joined: 19 July 2007 Status: Offline Points: 61 |
Post Options
Thanks(0)
|
Maybe you are right, but I don't worry about it when there is a workaround. I hope that this forum is read by CJ support and they will investigate the problem. I deleted the selected two rows with the modified sample and it works - or am I wrong? |
|
Product: Xtreme SuitePro (ActiveX) version 15.2.1
Platform: Windows 7 64 Bit Language: Visual Basic 6.0 SP6 |
|
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
Hi Peter,
If you upload sample, please add the right code to it I was testing with the old code from @markmark. To be honest I didn't look at the code as I wrote the previous reply. But it seems to be working as you say
Thanks
|
|
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2 Language: Visual Basic 6.0 Zero replies is not an option.... |
|
markmark
Senior Member Joined: 30 November 2007 Status: Offline Points: 142 |
Post Options
Thanks(0)
|
Hi All Thanks for all the replies I did contact support and this morning I got a reply. They said to use the following code Dim grdReportRow As ReportRow For Each grdReportRow In wndReportControl.SelectedRows If grdReportRow.GroupRow = False Then Call wndReportControl.RemoveRowEx(grdReportRow) End If Next However: This does not work if you select a child row. It seems that the index for a child row starts again. If you copy that code in the example I sent, you will see that selecting a child row and then run the delete code causes another row to delete. Or may be I’m missing the point in all this. I will now try Peters code and see what happens Thanks again |
|
Product: Xtreme SuitePro (ActiveX) version 13.0.0
Platform: Windows XP (32bit) - SP 2 Language: Visual Basic 6.0 |
|
Aaron
Senior Member Joined: 29 January 2008 Status: Offline Points: 2192 |
Post Options
Thanks(0)
|
Hi,
That is correct!!! Support didn't test this properly. If you use Peter's code it will work
Think I have something to do right now
|
|
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2 Language: Visual Basic 6.0 Zero replies is not an option.... |
|
markmark
Senior Member Joined: 30 November 2007 Status: Offline Points: 142 |
Post Options
Thanks(0)
|
Hi Peters Code is spot on. I did make a small addition (In Blue) For i = (wndReportControl.SelectedRows.Count - 1) To 0 Step -1 If wndReportControl.SelectedRows.Count > 0 Then lngCurrentCount = wndReportControl.SelectedRows.Count Set rptRow = wndReportControl.SelectedRows.Row(i) wndReportControl.RemoveRowEx rptRow If lngCurrentCount - 1 > wndReportControl.SelectedRows.Count Then i = i - 1 End If End If Next i If you have wndReportControl.GroupsOrder.Add Column added, so that the report groups by a column, its possible to select the group which adds to the selection count. But when that groups items are deleted the group row deletes its self. and is also removed from the SelectedRows object. So the count has changed, and variable i need updating
Hope that makes sense. I hope CJ will help, as its not very elegant. Thanks to you all MArk |
|
Product: Xtreme SuitePro (ActiveX) version 13.0.0
Platform: Windows XP (32bit) - SP 2 Language: Visual Basic 6.0 |
|
AndreiM
Moderator Group Joined: 18 August 2007 Status: Offline Points: 132 |
Post Options
Thanks(0)
|
Hello,
the problem is that SelectedRows collection used row indexes and RemoveRowEx does not update them.
To avoid this problem just save selected rows objects in separate collection.
EXAMPLE: Dim grdReportRow As ReportRow
Dim arToDel As New Collection For Each grdReportRow In wndReportControl.SelectedRows If grdReportRow.GroupRow = False Then arToDel.Add grdReportRow End If Next For Each grdReportRow In arToDel
Call wndReportControl.RemoveRowEx(grdReportRow) Next I will think about fixing RemoveRowEx to update SelectedRows collection
|
|
markmark
Senior Member Joined: 30 November 2007 Status: Offline Points: 142 |
Post Options
Thanks(0)
|
Thanks you AndreiM
Your code works good.
Thanks for looking into this
Regards
MArk
|
|
Product: Xtreme SuitePro (ActiveX) version 13.0.0
Platform: Windows XP (32bit) - SP 2 Language: Visual Basic 6.0 |
|
AndreiM
Moderator Group Joined: 18 August 2007 Status: Offline Points: 132 |
Post Options
Thanks(0)
|
Hello,
I have looked in RemoveRowEx implementation and find that row is removed from selected rows collection too. Let me advice other simple way to delete rows: ---------------------------------------------------------------------
Dim grdReportRow As ReportRow
While wndReportControl.SelectedRows.Count
Set grdReportRow = wndReportControl.SelectedRows(0) Call wndReportControl.RemoveRowEx(grdReportRow)
Wend |
|
markmark
Senior Member Joined: 30 November 2007 Status: Offline Points: 142 |
Post Options
Thanks(0)
|
Hi AndreiM
Thats very good. Much better looking and works!
Thanks very much
MArk
|
|
Product: Xtreme SuitePro (ActiveX) version 13.0.0
Platform: Windows XP (32bit) - SP 2 Language: Visual Basic 6.0 |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |