Hi,
I am using ControlContainerEditor to set a control on an UltraGrid.
I have a WinForm on which i have a Grid.
I am having a custom class - UserCondition, which I am using to set the data on the control.
As i read the property of ControlContainerEditor, it should set the value of UserCondition on the grid automatically but it is not.
UserCondition on the UltraGrid is always NULL.
That is why i am not able to access the object and the grid is not working.
Please advice.
Path to follow:
Run the program.
Select a value in the UltraCombo on the Form.
Click on the Add Condition button.
Add more than one conditions.
Choose some value in the Condition in a row of Grid.
As you click on the other row of the grid old values get lost.
Hello rajivd,
I was able to reproduce the issue you described in the version of NetAdvantage your sample originally used and in NetAdvantage 2013 Volume 1. My initial guess is that your user control is not interacting properly with the ControlContainerEditor. I will research this further and make another post when I have more information.
Hi Dave,
Please try to fix this issue as soon as possible as we have to deploy it for one of our clients on the urgent basis.
I took a look at your sample project and I beleive this is an issue with your code. When I follow the steps you listed here, your ChildUserControl never raises a PropertyChanged notification. You have a check inside of cmbConditionOperator_ValueChanged that when userCondition is null, you don't fire a notification. The grid therefore never knows that the row is dirty and so all changes are lost when you leave the cell.
In fact, it seems like this is correct, because changing the value in the combo does not change the UserCondition - it was null and it's still null. You have the same check in txtEditor_ValueChanged, as well. So no matter what you do, the UserCondition on your ChildUserControl will never change from null and no PropertyChanged notification will ever be fired.
Hi Rajiv,
rajivd said:so when i click on a particular row the editor goes into edit mode and is supposed to set that property automatically with the binded object which in our case is user condition.
Yes, when the cell goes into edit mode, the grid copies the value of the field in the data source to the property of the control that you specified. But the value in the data source is null. No one ever sets it to anything.
The reason for this is that you are doing something rather off here. You are binding the grid to a BindingList<UserCondition>. This means that each row in the grid represents a UserCondition item on the list.This means that each row in the grid will display the fields of a UserCondition. The UserCondition class has only one public field that I can see, and that's the ConditionType.
You are then, in InitializeLayout, hiding all of the bound columns (of which there is only one: ConditionType) and adding an unbound column to the grid called UserCondition. But this is just an empty, unbound column. You never populate it with any values, so it's always null.
The ControlContainerEditor operates on the value of a cell - it cannot alter or replace the entire row object itself. So what you really need here is a BinidngList of objects that have a UserCondition property and hook up that column to your editor.
i understand that we have placed that check. But my question is why is the user condition always null. As per my understanding of control container editor the editor is supposed to set the property("UserCondition") of embedded control ("ChildControl"). so when i click on a particular row the editor goes into edit mode and is supposed to set that property automatically with the binded object which in our case is user condition.
Also if you look at the code snippet of cmbConditionOperator_ValueChanged notify property changed will be fired once conditionoperator is set but as you also mentioned since the user condition is always null that statement never executes...
if (!this.isEditingControl || this.userCondition == null)
return; this.userCondition.ConditionOperator = (ConditionOperator)this.cmbConditionOperator.Value;// notify propert change will be fired when this value is set...
Thanks
Rajiv