Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I am a newbie in C#. Please HELP me.

Scenario:

I have a Form, named as frmModifyService. This Form will show service details which proceed earlier. In this Form there is a ListView, if I will select a Service ID from a ComboBox all the used componets of that service will load into the ListView. The ListView is named as lvSelectedItems. And that is perfectly working. This Form, frmModifyService will provide us the chance to edit services and its details including the service components in the ListView, lvSelectedItems. There are two Buttons besides the lvSelectedItems named as cmdAdd and cmdDelete. We can add more items into the lvSelectedItems. And also we can delete selected items from the ListView, lvSelectedItems. There is an another Button named as cmdUpdate. This Button helps us to update the current service details of a specific Service ID into my MySQL database.

Problem:

How do we know is there is any changes occurred in our lvSelectedItems while executing cmdUpdate_Click event? Please HELP I am stuck.

What I have tried:

I don't know how to work on this problem. So I didn't tried anything.
Posted
Updated 5-Sep-17 7:20am
v2
Comments
Richard MacCutchan 5-Sep-17 10:55am    
You need to keep track of every change. The sensible way of doing this is to update the database every time an item is added to or deleted from the list view. Do not wait for the user to click a button.

1 solution

I think you can better use a DataGridView, then you can make use of the IsCurrentRowDirty property.

If you want to stick to the ListView, just create a copy of the ListView e.g. named lvSelectedItemsOld, and compare that to the lvSelectedItems by using a for loop to cycle through all rows.
 
Share this answer
 
v2
Comments
.dot IT Solutions 5-Sep-17 13:23pm    
Thank you for your reply. All the things are already designed and lots of codes has been written. Now can't change the ListView or Form. Please give me a solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900