Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
310
Making Grid Readonly, then enable cell edit.
posted

I have an UltraGrid that I have made readonly by setting

 grdMapping.Override.AllowUpdate to false in the designer.

When the user right clicks, I want to have a context menu that pops up that has an option for the user to Edit the text of a cell.  I created a context menu to do this, and in ultraToolbarsManager1.BeforeToolDropDown event, I have code to determine which cell has been clicked. The code looks like this:

UIElement myUIElement;

UltraGridCell myCell;

Point currentMousePosition = new Point();

currentMousePosition.X = Control.MousePosition.X;

currentMousePosition.Y = Control.MousePosition.Y;

Point correctedMousePosition = this.tvItems.PointToClient(currentMousePosition);

myUIElement = this.grdMapping.DisplayLayout.UIElement.ElementFromPoint(correctedMousePosition);

myCell = (UltraGridCell) myUIElement.GetContext(typeof(UltraGridCell));

I then store the value of myCell and after the menu item is clicked, I call the following code: 

myCell.Activation = Activation.AllowEdit;

myCell.Activate();

this.grdMapping.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode);

The problem is that the cell still does not allow the value to be edited.

How do I make the cell editable?

Thanks,

 Gregg

  • 469350
    Verified Answer
    Offline posted

    Hi Gregg,

    It appears to me that you are expecting "myCell.Activation = Activation.AllowEdit;" to override the setting of AllowUpdate on the grid. I don't beleive this will work.

    Usually, the most specific setting (like a setting on a single cell) overrides the setting of any less specific settings (like a setting that applies to the whole grid). But in the case of allowing edits, it works the opposite way. The idea is that if you disable something, it should stay disabled, even if some part of it might be enabled. This follows along with standards of Windows. If you disable a panel, for example, nothing on that panel can be enabled individually. 

    In fact, this can't work, because if you take a look at the Activation property of the cell BEFORE you set it, you will find that it defaults to AllowEdit, anyway. So if this worked, the AllowUpdate property would never have any effect.  

    Anyway, this issues has come up before and there are lots of cases where you want to do what you are attempting here. So a property was added to the cell called IgnoreRowCellActivation. Setting this property to true allows the cell Activation property to be honored regardless of the CellActivation settings on the row or the column. I don't know if it applies to the AllowUpdate property, so you'll have to try that out and see. If it doesn't work, then I would recommend that you do not use AllowUpdate, but instead set CellActivation on all of your columns. That should allow the Activation on the cell to work once you set IgnoreRowColActivation.