title: problem with datagrid itemrenderer checkbox
body: <p>Please check the below code:
     userinfo.mxml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                 xmlns:s="library://ns.adobe.com/flex/spark" 
                 xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="init();"&gt;
      &lt;fx:Declarations&gt;
          &lt;!-- Place non-visual elements (e.g., services, value objects) here --&gt;
          &lt;!--Validation Start--&gt;
          &lt;mx:StringValidator source="{userNameInput}" property="text" 
                              requiredFieldError="Please enter only string"/&gt;
          &lt;mx:StringValidator source="{locationInput}" property="text" 
                              requiredFieldError="Please enter only string"/&gt;
          &lt;mx:Validator source="{genderfield}" property="selectedValue" 
                        triggerEvent="change" 
                        requiredFieldError="One Option must be selected"
                        listener="{wrapper}"/&gt;
      &lt;/fx:Declarations&gt;
      &lt;fx:Script&gt;
          &lt;![CDATA[
              import mx.collections.ArrayCollection;
              import mx.controls.Alert;
              import mx.events.ItemClickEvent;
              import mx.events.ListEvent;
              import mx.utils.ObjectUtil;
  
  
              private var mySO:SharedObject;
              private var _objValidation:ValidationField;
              [Bindable]public var dgItems:ArrayCollection = new ArrayCollection();
  
              public function init():void{
                  _objValidation = new ValidationField();
                  mySO = SharedObject.getLocal("newData","/");
                  if(mySO.data.info != null){
                      dgItems = mySO.data.info;
                  }
                  addbtn.label = "Add";
                  addbtn.addEventListener(MouseEvent.CLICK, call);
              }
  
              public function resetForm():void{
                  userNameInput.text = "";
                  locationInput.text = "";
                  genderfield.selection = null;
                  userNameInput.errorString = "";
                  locationInput.errorString = "";
              }
  
              public function addItem():void{
                  if(userNameInput.text != "" &amp;&amp; locationInput.text != "" &amp;&amp; genderfield.selection != null){
                      dgItems.addItem({name:userNameInput.text,location:locationInput.text,gender:genderfield.selectedValue});
                      resetForm();
                  }
              }
              public function savaData():void{
                  mySO.data.info = dgItems;
                  mySO.flush();
              }
  
              public function deleteRow():void{
                  while(datagrid.selectedItem != null){
                      dgItems.removeItemAt(datagrid.selectedIndex);
                  }  
                       addbtn.label = "Add";
                       resetForm();
              }
  
              public function dgChangeHandler():void{
                  addbtn.label = "Edit";
                  resetForm();
                  userNameInput.text = datagrid.selectedItem.name;
                  locationInput.text = datagrid.selectedItem.location;
                  genderfield.selectedValue = datagrid.selectedItem.gender;
              }
  
              public function call(event:Event):void{
                  if(event.currentTarget.label == "Add"){
                      addItem();
                  }
                  else if(event.currentTarget.label == "Edit"){
                      editRow();
                  }
                  addbtn.label = "Add";
                  resetForm();
              }
  
              public function editRow():void{
                  if(datagrid.selectedItem != null){
                      dgItems.setItemAt({name:userNameInput.text,location:locationInput.text,gender:genderfield.selectedValue},datagrid.selectedIndex);
                      resetForm();
                  }
              }
          ]]&gt;
      &lt;/fx:Script&gt;
      &lt;mx:Form x="250"&gt;
          &lt;mx:FormHeading label="User Information" fontWeight="bold"/&gt;
          &lt;mx:FormItem required="true" label="UserName" fontWeight="bold"&gt;
              &lt;s:TextInput id="userNameInput" restrict="A-Z a-z"/&gt;
          &lt;/mx:FormItem&gt;
          &lt;mx:FormItem required="true" label="Location" fontWeight="bold"&gt;
              &lt;s:TextInput id="locationInput" restrict="A-Z a-z"/&gt;
          &lt;/mx:FormItem&gt;
          &lt;mx:FormItem required="true" label="Gender" fontWeight="bold" width="210"&gt;
              &lt;mx:HBox id="wrapper"&gt;
                  &lt;s:RadioButtonGroup id="genderfield"/&gt;
                  &lt;s:RadioButton label="Male" groupName="genderfield"/&gt;
                  &lt;s:RadioButton label="Female" groupName="genderfield"/&gt;
              &lt;/mx:HBox&gt;
          &lt;/mx:FormItem&gt;
          &lt;mx:FormItem&gt;
              &lt;mx:HBox&gt;
                  &lt;mx:Button id="addbtn"/&gt;
                  &lt;mx:Button label="Reset" click="resetForm();"/&gt;
              &lt;/mx:HBox&gt;
          &lt;/mx:FormItem&gt;
      &lt;/mx:Form&gt;
          &lt;mx:DataGrid id="datagrid" x="550" y="20" dataProvider="{dgItems}" change="dgChangeHandler();"&gt;
              &lt;mx:columns&gt;
                  &lt;mx:DataGridColumn headerText="Visible" dataField="shouldDelete" textAlign="center" itemRenderer="CheckBoxRenderer"&gt;
                  &lt;/mx:DataGridColumn&gt;
                  &lt;mx:DataGridColumn headerText="UserName" dataField="name" textAlign="center"/&gt;
                  &lt;mx:DataGridColumn headerText="Location" dataField="location" textAlign="center"/&gt;
                  &lt;mx:DataGridColumn headerText="Gender" dataField="gender" textAlign="center"/&gt;
              &lt;/mx:columns&gt;
          &lt;/mx:DataGrid&gt;
          &lt;mx:HBox x="650" y="250" horizontalGap="30"&gt;
              &lt;s:Button label="Delete" click="deleteRow();"/&gt;
              &lt;s:Button label="Save" click="savaData();"/&gt;
          &lt;/mx:HBox&gt;
  
  
  &lt;/s:Application&gt;
  </code></pre>
  
  <p>and
  checkboxRenderer.mxml</p>
  
  <pre><code>package
  {
      import flash.events.Event;
      import flash.events.MouseEvent;
  
      import mx.containers.HBox;
      import mx.controls.Alert;
      import mx.controls.CheckBox;
  
      public class CheckBoxRenderer extends HBox
      {
          private var cb:CheckBox;
  
          public function CheckBoxRenderer()
          {
              super();
              cb.addEventListener(MouseEvent.CLICK, changeState);
          }
  
          public function changeState(event:Event):void{
  
          }
          override public function set data(value:Object):void{
              if(value!=null){
                  super.data = value;
                  removeAllChildren();
                  cb = new CheckBox();
                  addChild(cb);
                  cb.visible = true;
                  if(false){
                      cb.selected = true;
                      Alert.show("checkbox selected");
                  }
                  else{
                      cb.selected = false;
                      Alert.show("Checkbox unselected");
                  }
                  setStyle("verticleAlign","middle");
                  setStyle("textAlign","center");
                  setStyle("horizontalCenter","center");
              }
          }
      }
  }
  </code></pre>
  
  <p>can anyone please tell me why i can't get the value of checkbox selected?
  and when i select checkbox and then unselect the same checkbox i can't get back to Add button state.</p>