Feb 13, 2011
I am beginning to work with .NET technology after several years of VB6 and C++ and I want to learn as fast as possible.
View 6 Replies
My problem is with a DGV. It shows the prices of several store items, and I intend to let the user modify those prices by entering a % in a textbox (radio button states if that % is positive or negative) or by editing cell by cell manually.
As editing prices is kind of sensitive, what I do is loop through the DGV, add or substract the % engtered in the corresponding column and ask for a confirmation after whole DGV loop is done. If user agrees, DB is updated with new values. No problem here.
If user denies (in case he/she made a mistake), I restore grid's DataSource to a copy I made before calculating new percentages and this automatically refreshes my grid to its original state.
The issue is that if a user denies the operation for a 2nd time, this 2nd execution of the code fails at showing the original values, disabling the pseudo-rollback function.
Here is the code:
If MessageBox.Show(mensaje, "Actualizo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = DialogResult.Yes Then
remember this works OK if user denis once. What am I missing regarding DataSources or its Tables? Is there anything like .Redraw?
Btw, I tried update, refresh and I also used a sleep function (this helped me a few times back in VB6...).