Hi
I'm finding it very difficult to obtain an answer to this one, mainly because it is difficult to use keywords that don't return the more common binding queries. I will try to be as clear as possible ;)
As we know Ultragrids bind very well to lists of objects, which uses the object's class properties as columns. The type of data displayed in each column is governed by each property's type ie. ints and strings are displayed as ints and strings - bools as checkboxes etc.
But what if you want to the property to be some custom class ?
OK, so you can then bind as:
this.ultraDataSource1.Band.Columns.Add("CustomCol", typeof(string));
row["CustomCol"] = customClass.ToString();
That's great - but suppose then you want the column cell to display an image + text ? Or even have sub-rows (within the cell) of image + text ? With the ability to display a tooltip when you hover over different images and text ?
How do you set up Ultragrid and the custom class so that it binds properly ? Or would each cell contain it's own Ultragrid ?
Any help would be much appreciated !
Hi,
The WinGrid uses embeddable editors to display the values in the cell and also to allow the user to edit those cells. There are editors available which support all the standard data types.
If you are using a custom type, then there is, of course, no way for the grid to know what to do with it. So it will simply default to a basic text editor that displays the ToString method of the object and does not allow editing - since it cannot possible translate a string into the custom object.
So if you want to display something custom and allow the user to edit a custom class, you have to do a little extra work to allow the grid to handle this.
There are a number of ways you could do this, depending on what you wanted to do. It's hard to answer your question with any useful specifics without knowing exactly what your requirements are. The grid already has the ability to display image and text in a cell, so you could handle that using one of the existing editors and maybe use an unbound column or a DataFilter.
For more complex cases, like displaying a grid inside a grid cell, you would probably want to use the UltraControlContainerEditor, which is a component that lets you embed any control you want inside a cell.
Hi Mike
Thanks for responding back so quickly.
To clarify, we don't need users to be able to edit the cells...
The application is to display clockings for a particular person - hence the grid only needs to display one row between each refresh, with days as the column headings.
There are date controls to alter the date range, so column headings will change dynamically.
So the number of could clockings can vary for each day - and for each clocking we need to show an icon (IN or OUT) along with the clocking details.
I hope that clarifies our requirement
thanks