Hi, I'm playing around to find the best approach to display my task schedule in win grid.
In the first column down, employees should be displayed. To the right, every column stands for one day containing the working task for one employee. My business object has therefore two lists of objects: One list of objects A (employe plans), and every object A has a list of object B (tasks per days).The same day can have more than one task.
Is it possible to bind my business object directly to grid? How I can achieve that the days are generated to columns not rows (pivot) ?
Another approach I'm thinking about is to use UltraDataSource and setup bands and columns from code depending of my business object.
Thanks for any suggestions.
Markus
Thanks or the information Mike.
If I have more questions, I will reopen the post.
Thank you. Markus
Hi Markus,
When the user updates a cell in the grid, then the grid will automatically write that data to the UltraDataSource (or whatever DataSource it is using) based on the UpdateMode property. By default, the grid saves the changes to the data source any time you move out of a cell or the grid loses focus.
UltraDataSource is intended to allow you to build the data manually. It's not really designed to work with a back end (database). So it does not track changes like a DataTable or DataSet does. If you want to track changes, you would have to do so yourself. I recommend using AfterCellUpdate or AfterRowUpdate events. You may need to handle the BeforeRowsDeleted event if you are allowing your users to delete rows.
Hello Mike,
Trigger changes: I mean if the user makes changes to the data in the grid. For grids bound to a dataSet, I can select the changes from the dataSet and update it by the table adapter. In this case of binding to ultraDataSource do I have to trigger the cellDataChange events and update my business object and setting some persitient state manually (changed, new, deleted)? Which events to trigger (grid or ultraDataSource) for that?
Thanks. Markus
mac_swit said:After that data rows are added to the dataSource. The dataSource event RowAdded is called right know when the row is added. But the Initialize_row event of the grid is not added immediatly. It is called "later"? How is the Initialize_row event triggered?
When you add a row to the UltraDataSource (or any IBindingList data source), the data source sends a notification through the IBindingList interface that something has changed. Any bound controls, like the grid, watch for this notification. But the grid doesn't necessarily respond to this notification synchronously. Responding to every notification immediately would lock up your whole application any time your data source underwent a lot of changes at once.
So the grid just tracks that something has changed and then it updates itself the next time it paints. So that's when InitializeRow will fire.
mac_swit said:Another problem is that I have different type of rows. I can tag new rows when adding to the ultraDataSource, but in the Initialize_Row event of the grid, the tag information is lost. Do I have any possibility to get the ultraDataRow associated by the UltraGridRow? Just by indexof the bands row collection?
The UltraGridRow exposes a ListObject property, which returns the underlying data object in the data source - in this case, an UltraDataRow.
mac_swit said:And last but not least: how to track changes? Trigger change events and set persistent state in the data?
I'm afraid I do not understand your question.
Hi Mike,
the UltraDataSource is confusing me. I define the data structure of the dataSource (3 bands and columns in each band). After that I bind the dataSource to the grid -> Initialize_Layout event of the grid is fired. So far as expected.
After that data rows are added to the dataSource. The dataSource event RowAdded is called right know when the row is added. But the Initialize_row event of the grid is not added immediatly. It is called "later"? How is the Initialize_row event triggered?
How are the events of the ultradataSource and grid working together? User should be able to add, remove, change copy, paste, .......cell data in the grid. Which events to trigger?
Another problem is that I have different type of rows. I can tag new rows when adding to the ultraDataSource, but in the Initialize_Row event of the grid, the tag information is lost. Do I have any possibility to get the ultraDataRow associated by the UltraGridRow? Just by indexof the bands row collection?
And last but not least: how to track changes? Trigger change events and set persistent state in the data?
Thanks for your help.