This is a migrated thread and some comments may be shown as answers.

EditorRequiredEventArgs.Editor always null

7 Answers 113 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Phillip
Top achievements
Rank 1
Phillip asked on 11 Aug 2009, 10:53 AM
Hi,

I have a grid (2009 Q2) with a number of GridViewComboBoxColumn attached to them, each of which is populated from an array data source. I wish to highlight one of the items in the combo when it is dropped down for some reason (i.e. changing the font to Bold). To do this I intercept the EditorRequired event to get access to the default editing control being supplied for the cell - my idea is that I can access the created control and manipulate its contents. Here is my method

static

 

void grid_EditorRequired(object sender, Telerik.WinControls.UI.EditorRequiredEventArgs e)

 

{

Telerik.WinControls.UI.

RadComboBoxEditor comboEditor = e.Editor as Telerik.WinControls.UI.RadComboBoxEditor;

 

 

 

if (comboEditor != null)

 

{

Telerik.WinControls.UI.

RadComboBox comboBoxControl = comboEditor.EditorElement.ElementTree.Control as Telerik.WinControls.UI.RadComboBox;

 

 

// Do some work with the combo box control here

 

}

}

However the e.Editor is always Null (the e.EditorType is typeof(RadComboBoxEditor) as expected).

I see from several postings that I would expect to have an instance of the RadComboBoxEditor in the e.Editor property, and that this event is the correct one to do what I'm trying to do.

In addition, other posts have been shown solutions which show that RadComboBoxEditor class has an Items collection, but in my edition of Rad this property does not exist, and I'm guessing my route through to the combo box items collection is through .EditorElement.ElementTree.Control.

Can you help untangle this for me ?

7 Answers, 1 is accepted

Sort by
0
Daniel
Top achievements
Rank 1
answered on 11 Aug 2009, 02:26 PM
In my project, I use EditorRequired to set both data sources and format of combo box editors (mutli column ones most of the time). In Q2 2009 args.Editor is suddenly null and I had to find alternate solutions, in some cases unsuccessfully. Is this WAD or just a bug? Thx in advance.

Daniel
0
Phillip
Top achievements
Rank 1
answered on 11 Aug 2009, 03:24 PM
Daniel,

It sounds like this is a recently introduced bug in Q2 2009. I look forward to Telerik's reply to this.
0
Daniel
Top achievements
Rank 1
answered on 11 Aug 2009, 06:34 PM
Yes Phillip, it looks like it. I'm also curious what will telerik tell us about it.
0
Accepted
Nikolay
Telerik team
answered on 12 Aug 2009, 09:21 AM
Hello Daniel and Phillip,

The behavior that you experience is not because of an issue, but it is because we changed the way our editors work.

The EdtiorRequired event is fired when an editor is required, because RadGridView gets in edit mode. This is the correct event to replace the default editor of the column with your own editor as demonstrated in this help article. Please note that this is not the correct event to take the editor that will be shown, since the editor is assigned either by you in the EditorRequired event handler of automatically after the event is over.

The correct events to take an editor are CellBeginEdit or CellEditorInitialized. CellBeginEdit is fired when the editor is already available, but it is not still initialized - i.e. the initial values for its properties are not set. CellEditorInitialized is fired when the editor is initialized and it is ready to be shown.

You can see CellBeginEdit and CellEditorInitialized in use in this help article. The rest of the articles that regard editors will be updated with the new information soon.

Phillip, please note that the EditorElement property of an RadComboBoxEditor gives you access to the RadComboBoxEditorElement. This element contains the Items collection and other properties that can customize the element.

I hope this helps. If you have additional questions, feel free to cotnact me.

Sincerely yours,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Daniel
Top achievements
Rank 1
answered on 12 Aug 2009, 09:26 AM
Hi Nikolay,

I had suspicion that you change the way it work. Thats ok. But what concerns me and doesn't please me at all is that you didn't document this breaking change. It is not mentioned in "What's new" nor in the documentation. I'd appreciate if such changes would be better communicated next time. Or am I just ignorant and missed something?

Best regards,

Daniel
0
Phillip
Top achievements
Rank 1
answered on 12 Aug 2009, 11:20 AM
Nikolay,

I see the logic in this, however agree with Daniel - its a breaking change and your forum solutions have not been deprecated and lead people like me into implementing a previously working solution which you now know to be faulty. Luckily I personally didn't spend a long time trying to work out what was wrong, such is the excellence of the support provided through these forums, however your documentation and online help are clearly in error; 

http://www.telerik.com/help/winforms/grid_gridviewcomboboxcolumn.html

says "In order to access the RadComboBoxEditor, you should subscribe to the EditorRequired event of RadGridView. The event arguments of this event contain the editor itself. So, you can get the editor and subscribe to its events or set different properties", so this is an issue, either in the documentation or the software. Just need a little more attention to detail on the synchronisation of the documentation with the Quarterly released I suspect; I'm not going to lose any sleep over it, but should we really need to regression test every last part, and exercise every event handler of our applications after taking the latest release ?
0
Accepted
Nikolay
Telerik team
answered on 13 Aug 2009, 02:26 PM
Hello Phillip and Daniel,

The improvements made in regards to the RadGridView editors are mentioned in the Q2 2009 release notes:

"Improvements:
RadGridView editors system. Now it is possible to change the behavior of the editors and create custom ones

Fixes:
Breaking Change in the Editor's system: Now all editors are not RadElements. They implement the IInputEditor interface or inherit from BaseGridEditor. You should use the EditorElement property to access the underlying RadElement."

In addition, we covered the most popular scenarios in new help documentation articles:
Editors, API, Events, Customizing Editor Behavior, Using Custome Editors. In these articles you can find the general principles of the techniques that you need to know when working with the new editors.

What we did not make on time for the release was updating the old articles regarding the old editors. As I mentioned before, these articles will be updated shortly.

As to the forum posts, they are discussions about old issues or solutions for older versions of our RadControls. These solutions might still be useful for those using older versions of RadControls for WinForms, therefore we do not intend to edit old forum posts unless someone asks for our help. It is more natural for a Knowledge Base article to have a 'deprecated' tag, however we do cover this case by mentioning the version the article is for.

Last, but not least, is the topic regarding the breaking changes in the new versions. Although we strive to keep the number of breaking changes at its minimum, it is necessary for some of the improvements to be accompanied by breaking changes. In some cases such changes just can't be avoided.

I hope this helps. If you have additional questions, feel free to contact me.

Kind regards,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Phillip
Top achievements
Rank 1
Answers by
Daniel
Top achievements
Rank 1
Phillip
Top achievements
Rank 1
Nikolay
Telerik team
Share this question
or