Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
761
Data type definition on cell level
posted

Dear Mike

Hopefully you can give me some advice on how to manage the following:

We have a bunch of business objects with properties of multiple data types. Form these I am constructing a 2-dimensional array with I convert to a UltraDataSource that is bound to an UltraWinGrid in virtual mode. The array is based on my own "Cell" type. I have derived Cell types for DateTime, String, Double etc. The Cell type implements IConvertible to supply the necessary interface to allow binding a Cell value to my UltraDataSource, which I inherited. This works perfectly:

// My custom UltraDataSource 

protected override void OnCellDataRequested(CellDataRequestedEventArgs e) { e.Data = this.data[e.Column.Index, e.Row.Index];

e.CacheData =

false; // virtual gridbase.OnCellDataRequested(e);

}

Now here comes my question: My UltraDataSource is created by adding columns, based on the horizontal dimension of my Cell array, and setting the row count based on the vertical dimension of my Cell array. Every cell could have a distinct data type, so I assume I need a "generic" data type to create the columns (e.g. object). How can I force the grid to use the correct cell editor when the column is only of type object?

I know that I can get access to the cell by this code in the grid:

UIElement uiElement = this.DisplayLayout.UIElement.ElementFromPoint(new Point(e.X, e.Y)); UltraGridCell cell = (UltraGridCell)uiElement.GetContext(typeof(UltraGridCell));

How can I access the data type of the cell, and - based on this infromation - provide the correct editor for the cell (or mask) ? I could also image to provide a somewhat Excel like grid with formatted cells. Is there a way to do that?

I hope my notes are somewhat understandable for you. Any help is very much appreciated, thanks.

Frank