User (Old forums)MemberNovember 4, 2008 at 4:30 amPost count: 23064
I am writing a class that inherits from CellEditorManager. This class is used for displaying a control in the cell based on the current row. The row determines the type of control that needs to be displayed in the cell, which is causing me some problems:
1) The ‘TempateControl’ is expected in the base constructor of CellEditorManager. I do not know what control needs to be created at this point, as it is determined by the value on the current row. Is there any other way I can set the ‘TemplateControl’ using a protected method/property?
2) Another problem is that I need access to the row in the overridden ‘CreateControl’ method. This is because I need to read a value from the SourceObject on the row to determine which control to add to the cell to show the user. The ‘CreateControl’ has no EventArgs (as it’s not an event) nor method parameters, so it’s not possible to get the current row unless I manually pass the Grid into my CellEditorManager and read the currently selected row manually. I was hoping that there would be an event that fires before CreateControl where I could grab the current row and keep hold of it for the ‘CreateControl’ method. Can you please advise?
3) The CellEditorManager sometimes loses the controls value. Depending on a value on the current row’s SourceObject, I might need to display a custom UserControl that gives the user extensive search capabilities. This UserControl, as it is custom, requires certain properties to be set and methods called before it can work correctly. I can get this control to render in the grid with no problem, and implementing the ‘SetControlValueCore’ method allows me to successfully set the value of the control. The problem is that when I try to read the value of my control’s Text property in ‘GetControlValueCore’ from the ‘Control’ parameter, the value is always “”. This is always the case, irregardless of the value I return when I override ‘CreateControlMode’. The only way I can overcome this is to store the control I create in ‘CreateControl’ locally in the CellEditorManager and then read the Text value from this within the method ‘GetControlValueCore’. Is there anything I can do to successfully use the ‘Control’ parameter provided to me in ‘GetControlValueCore’?
I appreciate any advice given.
Imported from legacy forums. Posted by russellcoombes (had 1278 views)User (Old forums)MemberNovember 4, 2008 at 4:43 pmPost count: 23064
Two possible solution. First, if the value does not change once it is loaded into the grid, you could use the AddingDataRow event on the GridControl, and in the event handler, verify the value in the cell, and set the CellEditorManager to the control needed in the other cell.
Second, you could use a Panel as the TemplateControl for your custom CellEditorManager. Then your panel could contain the different controls you need. In the SettingControlAppearance override, you could verify the cell.ParentRow to find the other cell value, and choose which control you want to display, and hide the others.
Imported from legacy forums. Posted by André (had 305 views)User (Old forums)MemberNovember 5, 2008 at 3:42 amPost count: 23064
Number 1 option won’t quite work for me as I want this to be more generic as something that can work with multiple Xceed Grid instances.
But your second idea is a very good one. It’s not a million miles away from what I have at the moment, but your idea is definate improvement. It also confirms that you would need to manage the control’s value by manipulating a local copy of the control rather than using the one provided within the EventArgs in the overridden GetControlValue and SetControlValue methods.
Thanks a lot for your ideas and feedback Andre – it’s much appreciated.
Imported from legacy forums. Posted by russellcoombes (had 474 views)User (Old forums)MemberNovember 19, 2008 at 3:54 amPost count: 23064
As an update to this thread, please note that my attempt to create the correct control in CreateControl did not work as the CreateControl gets fired only once, and obviously, I needed it to fire for each row as different rows contained different controls.
So to get this to work correctly, I used Xceed’s suggestion of using a Panel as the TemplateControl and then determining which controls can be seen in the SetControlValue method – which is working perfectly.
Imported from legacy forums. Posted by russellcoombes (had 1090 views)
- You must be logged in to reply to this topic.