Hi, here is my code snippet when i used EditorControl
ultraGridCell.EditorControl = textEditor;
ultraGridCell.EditorControl.Name = propertyName;
and i am validating like this...
if (cell.EditorControl == null || !cell.EditorControl.Name.Equals(propertyName))
Now, i want to replace EditorControl with EditorComponent. How to implement the same functionality with EditorComponent.
Thanks Mike. It's working now.
Like I said, clearing the child controls of the EditorControl is an extremely dangerous thing to do. You should not be doing that, and I don't understand why you are doing that. I'm surprised this isn't causing serious problems in your application.
In fact, I'm not sure why you are doing anything in this block of code. There's no reason to set the EditorComponent or the EditorControl to null and then immediately set it to something else. Why not just set it directly to the new component?
If, for some reason, you feel you need to clear out the existing EditorComponent before you assign the new one, then just set it to null. There is no reason to clear it's Controls collection.
Hi Mike,
Thanks for your reply.
if (e.Cell.EditorControl != null) { e.Cell.EditorControl.Controls.Clear(); e.Cell.EditorControl = null;}
I am clearing the controls in the editorcontrol of the cell and i again add UltraTextEditor each time based on my validation. So, please let me know how to clear the controls if EditorComponent has to be used instead of EditorControl.
Hi,
Why are you doing this?
e.Cell.EditorControl.Controls.Clear();
You are clearing the controls collection from inside the editor? That's a very dangerous (and completely unneccessary) thing to do.
Anyway, I pretty much gave you the code you need.Replace your second 'if' statement with the one I posted in my previous reply. Then just change EditorControl to EditorComponent.
Control editorControl = cell.EditorControl;if (editorControl != null && editorControl.Name.Equals(propertyName)){ cell.EditorComponent = ultraTextEditor; editorControl = propertyName;}
Here is the code which i am using now:
if
(e.Cell.EditorControl != null)
{
e.Cell.EditorControl =
null;
}
(cell.EditorControl == null || !cell.EditorControl.Name.Equals(propertyName))
cell.EditorControl = ultraTextEditor;
cell.EditorControl.Name = propertyName;
In the above code, i want to replace EditorControl with EditorComponent. How to do that?