Sometimes I lock my Winforms UltrGrid columns, depending on application variables. If the user saves the grid layout while those columns are locked, I cannot unlock the columns.
If blnMyProgramCondition Then grdGrid.DisplayLayout.Bands(0).Columns("Entity").CellActivation = Activation.Disabled grdGrid.DisplayLayout.Bands(0).Columns("Entity").CellAppearance.ForeColorDisabled = Color.Black grdGrid.DisplayLayout.Bands(0).Columns("Entity").CellAppearance.BackColor = Me.BackColor Else grdGrid.DisplayLayout.Bands(0).Columns("Entity").CellActivation = Activation.AllowEdit End If
If blnMyProgramCondition Then
grdGrid.DisplayLayout.Bands(0).Columns("Entity").CellActivation = Activation.Disabled
grdGrid.DisplayLayout.Bands(0).Columns("Entity").CellAppearance.ForeColorDisabled = Color.Black
grdGrid.DisplayLayout.Bands(0).Columns("Entity").CellAppearance.BackColor = Me.BackColor
Else
grdGrid.DisplayLayout.Bands(0).Columns("Entity").CellActivation = Activation.AllowEdit
End If
The above works fine unless I load the grid layout first (in which the columns were locked before saving):
grdGrid1.DisplayLayout.LoadFromXml("MyLayout.xml")
Ok, I fixed it. Turns out that there was a second recall layout going on after the one I was looking at. Once I did these three lines AFTER the final recall layout it was all good: grdGrid.DisplayLayout.Bands(0).Columns("Entity").CellActivation = Activation.Disabled grdGrid.DisplayLayout.Bands(0).Columns("Entity").CellAppearance.BackColor = Me.BackColor grdGrid.DisplayLayout.Bands(0).Columns("Entity").CellAppearance.ForeColorDisabled = Color.BlackThanks for your help on this!
So this layout file is setting the CellActivation property on the "Entity" and Location columns to Disabled.And it sets the CellActivation property on the "Total" column to NoEdit.
AllowUpdate and CellClickActionon the Override for the DisplayLayout and the Band Override both allow editing. So that's not the problem.
That's a little confusing, because it sounds like you are saying that you can click in the cell and get a caret, but you can't type. If the column was disabled, then you would not be able to enter edit mode and get a caret at all.
So it sounds like either the CellActivation is set to one of the other settings like ActivateOnly or NoEdit. Perhaps it's getting set somewhere else in your code? Or... I think that might be the behavior you'd get if your data source doesn't allow editing. Or maybe something in your application is just eating the keystrokes, like the KeyDown event? Seems unlikely.
Sorry, this should be the right link: https://1drv.ms/u/s!Ar3QB3PmXuPTnepOdtCvKLj9R9Go8Q?e=26RI3e
I will take a look at the things you suggested tomorrow.
Hi,
I don't think the file you attached is the correct one. This does not appear to be an UltraGridLayout xml file. The file you attached here is only 3 lines of XML and does essentially nothing.
If the DisplayLayout.Override, the Band.Override, and the column are all set to allow editing, then the other possibilities to disallow editing on a cell would be the row.
So you could check your code to see if you are setting "Activation" on the row or cell.
You could also, at run-time, get a reference to one of those cells and output: cell.ActivationResolved just to see what it returns. If it's returning anything other than AllowEdit, then we know that some property setting in the grid is the issue here.
Another possibility is that your data source simply doesn't allow editing. But that would have nothing to do with loading a layout. So unless you are loading a layout and ALSO changing the data source, that wouldn't make sense.
One final possibility is that you are handling some grid event like BeforeEnterEditMode and setting e.Cancel to true. That would prevent the cell from editing, as well.
Thanks for taking the time to help me on this. I am now setting those two properties to true after loading the layout, but it is still keeping those columns locked. Please see attached ZIP file of the layout.
This is the code I am using to try to unlock the columns after loading the layout:
grdGrid.DisplayLayout.Bands(0).Columns("Location").CellActivation = Activation.AllowEdit grdGrid.DisplayLayout.Bands(0).Columns("Entity").CellActivation = Activation.AllowEdit grdGrid.DisplayLayout.Override.AllowUpdate = DefaultableBoolean.True grdGrid.DisplayLayout.Bands(0).Override.AllowUpdate = DefaultableBoolean.True
This is the result - columns are still locked.
Here is a link to download the ZIPped layout file - I couldn't see where to upload it here. Note the layout file was saved as locked. I am running the above code AFTER loading the layout, but it is not unlocking.
https://1drv.ms/u/s!Ar3QB3PmXuPTnepNykwRCFx7GaH61Q?e=yqDMSH
Thanks again!