Hi.
Imagine a grid with two columns, the first let you to choose a field type, (Ex. True/False, Value list, Text) and the second must show an UltraEditor depending on the selected type. And it can be different on the next row.
Is this possible?
Of course, I can detect CellClick event and open a popup window, but I would like to use a smarter solution.
Thanks.
Ok Mike, let me try this way.
Thanks a lot.
Hi,
Building your own editor from scratch is a pretty daunting task. We do have a sample of that under the WinGrid samples. it's called RichTextEditor. But frankly, writing your own editor is a tremendous amount of work and there is a much easier solution.
I recommend using the UltraControlContainerEditor. This is an editor that essentially allows you to embed whatever control you want in the cell. And I think it would be an excellent solution for what you want to do.
So you would create a control that can handle any of the data types you need. One caveat is that the control won't be able to access the other cells in the row. It only communicates with the grid through a single property - the value of the cell. So you need a single property on your control that will tell it both how to display and also what value to display. If the "how" is determined by the data type, then that would be pretty simple - your property would just be an object and then depending on the type of object applied to that value, you could change the UI. If the data type of the value is not sufficient, then things get a bit trickier. You would need to create a class that includes both pieces of information (what to display and how to display it) and then create a column in the grid of that type.
Ok, can I build a personalized Editor for this task?
Is there any sample that can show me the way?
Yes, you can set the EditorComponent or Editor property on the cell. But this can be a bit tricky, because the DataType of the column applies to all of the cells. So you would have to use a DataType that is compatible with all of the editor types you intend to use.