HI
All the cells in my ultrawingrid are editable.
For every row there is a button called Save.
So when I change the value of a cell in a particular row and clicks on other row without saving
it should prompt the user that changes will be lost, do you wish to continue without saving with yes no options.
When user clicks yes - all the changes should be undone and active row should be the row that user clicked.
When user clicks no - changes will remain same and the active row should be the row that user made changes.
Also when the other control got focus (when grid lost focus)it should prompt the user if changes are made.
Please help me how to do this. I have done this but with many flags and low preformance code.
Hi Sandy,
I'm afraid I do not understand your question. A BindingSource is essentially a wrapper for an object you want to use as the DataSource of some bound control. So you would simply set the DataSource of the grid to your BindingSource.
This has nothing to do woth updating the database, though. The grid only deals with the local data source, never the database directly. If you need information on how to retrieve and update data in a database, you should probably check out Microsoft's documentation.
How do I use bindingsouce control to my ultrawingrid?
so that it has to update the database automatically means on some button click it has to update the current row information in the database with proper validations.
Okay, I think I understand now. When you click the button, you are directly updating the data source. But if the grid is bound to this data source and has pending changes to the row already, then this probably won't work. Or at least, I'm not sure what will happen in this case. It seems to me that what you need to do is call the Update method on the row before you start to modify any of the values on the objRate object. This will commit the changes to the current row.
But manually copying the data from the grid into the data source doesn't seem like a good idea. Why are you doing it this way? If the grid is bound, it will automatically update the data source and you don't need to do it manually like this.
sandeepkashaboina said:ugRate.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.CommitRow, True, True)
Calling Update on the row will accomplish the same thing in an easier way. The Shift and Control parameter here refer to the shift and control keys on the keyboard. PerformAction simulates user interaction with the grid. But that's not really what you need here.
This is what the columns I had in my grid:
Normal 0 false false false EN-US X-NONE X-NONE /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;}
So when I click on save button (the last column in the selected row),
based on the PKLoandID the selected row will be updated in the database.
Now I change some value in the selected row
let's say:
the rate type now is "Note Rate", I will change this to "Default Rate" and when click on save, the corresponding information is saved in to database. And on row change after save BeforeRowUpdate should not fire because it is saved.
Code:
Private Sub ugRate_ClickCellButton(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.CellEventArgs) Handles ugRate.ClickCellButton
Dim objRate As New LoanRate
objRate.PKLoanRateID = ugRate.ActiveRow.Cells("PKLoanRateID").Value
objRate.RateType = ugRate.ActiveRow.Cells("RateType").Value
objRate.Rate = ugRate.ActiveRow.Cells("Percentage Rate").Value
objRate.StartDate = ugRate.ActiveRow.Cells("Start Date").Value
objRate.EndDate = ugRate.ActiveRow.Cells("End Date").Value
objRate.Notes = ugRate.ActiveRow.Cells("Notes").Value
LoanRateBO.saveRate(objRate)
End Sub
Since the value is changed BeforeRowUpdate is firing even after the ClickCellButton which should button.
I also wrote the following in the above code but not worked.
ugRate.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.CommitRow, True, True)
can you also please explain me the arguments of this PerformAaction function.
(shift as boolean, control as boolean)
thanks in advance
I'm afraid I am still having a hard time understanding your question.
If BeforeRowUpdate is firing, it means that there are unsaved changes to the row that are being committed to the grid's underlying data source.
It's not really clear what exactly you mean when you say "save" here. Do you mean committed the changes from the grid to the data source or do you mean committed the changes from the data source to the back end?
What exactly is your button code doing?