i have an ultraWinGrid which has its datasource being set to an arrayList. This is an arrayList of a class which public properties. I want to be able to edit this grid after i set its datasource to the arrayList. I also define the columns through code so i know the key, valueMember, displayMember, friendlyName.
Hi,
What part of this is giving you trouble and how can I help?
The problem is being able to edit this grid. I cant edit the rows. The first version of the application had an ultraDataSource for the grid along with dataRows being defined and inserted into the grid. Now I need to find a way to edit this grid now that it is using an arrayList as its datasource
Hi Mike,
Thanks for your quick reply !
Using a DataAdapter isn't really a solution (most of my code is generated, including the DataAccessLayer)
But I found a solution.
I'm keeping an extra property IsModfied with each Entity.
This property is filled up in the
<grid>_AfterRowInsert () and
<grid>_AfterRowUpdate() methods
At then end (when the user clicks the "Update Database" button),I'm looping through my collection of Entities, and execute the necessary DB actions, depending on the IsModified property.
So, solution found.
Once again, thanks for your help and the great product.
Grtz,
Johnny Driesen
Belgium
Hi Johhny,
The grid does not track changes like this. The grid only deals with the data source. The interaction between the data source and the back end is outside the grid's purview.
So it's the responsibility of the data source to track changes like this. The DataSet/DataTable in DotNet do this for you automatically and you would typically use the DataAdapter class to update the back end. Microsoft documentation has more details on how to do that.
I had the same problem.
Now, how can I find out which lines have been changed in my grid (i.e. : Added, edited or deleted ?)
I want to write my changes in "one move" to the database.
So, is there a property in the grid which tells me if rows are changed ?
(or do I have to keep track about it ?)
Thanks in advance for your reply.
Johnny
Thanks a lot Mike. Been a great help.
Well, if the data source is not updateable, then the grid won't be. I can't see any reason why an ArrayList would not be updateable... but it's probably not the best choice of data source for the grid, especially if you need to allow the user to add new rows. Since ArrayList implements IList and not IBindingList, the grid won't be able to add rows - but it should still be able to edit, assuming that the properties of the items in the ArrayList are get/set.
I would recommend using a BindingList<T> rather than an ArrayList, if you can.
Try binding the same ArrayList to a new grid that you place on the form. If the new grid doesn't allow editing the rows, then this must be an issue with the ArrayList, because the grid allows editing by default.
If the new grid allows editing, then this must be the result of some property setting you are applying to the grid. This KB article gives you a list of all the ways you can disable editing in the grid, so check and see if you are setting any of these properties: HOWTO:How can I make a grid or a column, row, or cell in the UltraWinGrid disabled or read-only?
Be sure to also check if you a loading a layout or a preset into the grid which might be setting properties to disable editing.