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 !
There are sample DrawFilters all over the forums. Maybe not for exactly what you want, but I'm sure there are some samples that are very similar. Search the forums for "IUIElementDrawFilter" and you should find a bunch of them.
For samples of using UltraControlContainerEditor, there is a sample that installs with NetAdvantage.
Which approach you take here depends mainly on how comfortable you are with GDI Plus or writing your own controls. If you have used the Graphics object before to do your own drawing, then the DrawFilter is probably the way to go. If you are more comfortable using a control, like the grid, to get the display you want, then you will probably be better off with a UserControl that has a grid on it.
The DrawFilter approach is also more efficient, since it doesn't require any new controls to be created.
Also, one other thing to note is that when your date range changes, the grid doesn't have any way to know about it, so you will need to call grid.DIsplayLayout.UIElement.DirtyChildElements to tell the grid to recreate the elements in the custom column. This is the same regardless of which approach you decide to take.
Hi Mike
No the date controls are separate to the grid and we only need the cell to display data.
I will check out both methods you suggest. Are there any simple examples of these ?
thanks
Hi,
Are the date controls inside the cell or outside the grid?
If they are outside the grid and you only need the cell to display data and the user never needs to interact with a cell or change anything in the cell, then you could implement this in a couple of ways.
If the date controls are going to be inside the cell and the user needs to edit them, then the cell data will have to contain all of the date range information as well as the data to display and it you will have to use option 2 with both a RenderingControl and an EditingControl.
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
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.