danielkelly
IS-IT--Management
Hi,
I have a DataGridView control on a POS application I am writing as a project. I am having issues when trying to remove certain items from the control. Below is an example :-
1 Item 1 $5.00
-Extra 1
-Extra 2
1 Item 2 $10.00
1 Item 3 $2.00
-Extra 1
I want the user to be able to click on an item (or extra) in the datagridview and delete it. I can do this for single items and extras and it works perfectly (using removeat)but when I select an item, I want to check if there are any "extras" associated with the item and remove them aswell. Extras are always immediately below the item in question. My stumbling point seems to be when I remove 1 using RemoveAt, the index numbers change and I get exceptions.
This datagridview is not bound to any datasource and I am creating it on the fly.
Any help with the logic would be muchly appreciated.
Thanks,
Daniel.
I have a DataGridView control on a POS application I am writing as a project. I am having issues when trying to remove certain items from the control. Below is an example :-
1 Item 1 $5.00
-Extra 1
-Extra 2
1 Item 2 $10.00
1 Item 3 $2.00
-Extra 1
I want the user to be able to click on an item (or extra) in the datagridview and delete it. I can do this for single items and extras and it works perfectly (using removeat)but when I select an item, I want to check if there are any "extras" associated with the item and remove them aswell. Extras are always immediately below the item in question. My stumbling point seems to be when I remove 1 using RemoveAt, the index numbers change and I get exceptions.
This datagridview is not bound to any datasource and I am creating it on the fly.
Any help with the logic would be muchly appreciated.
Thanks,
Daniel.