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")
Hello Ted,
Thank you for contacting Infragistics Developer Support!
What do you mean when you say the columns are locked?Do you have a sample you can attach?
Locked for editing; the cursor can enter the cell but you can't edit or change anything, and the drop down button is disabled. This is what I want in certain circumstances. However, after doing the DisplayLayout.LoadFromXml("MyLayout.xml") I don't seem able to re-enable the locked columns. Sorry I don't have a sample - the screen actually has 6 grids on different tabs and is part of a much larger application. Extracting it for a demo would be a job in itself.
Cells in the grid will take on the least accessible Activation setting. So, for example, if you disable editing in the entire grid, or on the Override, then nothing you do on the cell, row, or column will re-enable editing in that cell.
So what's most likely happening here is that your layout is applying a setting to your grid that is disabling editing on a higher level, like the DisplayLayout or the Band which is essentially overriding the CellActivation setting on the column. So the simplest thing for you to do would be to load the layout and then examine the CellActivation property on the Band and the DisplayLayout over your grid to see which one is doing it, and then undo that setting.
So take a look at these two properties: Me.UltraGrid1.DisplayLayout.Override.AllowUpdate Me.UltraGrid1.DisplayLayout.Bands(0).Override.AllowUpdateChances are, one of them is set to DefaultableBoolean.False and that's what is stopping you from editing the column. If that doesn't help, zip up your layout file and attach it here and we can take a look at it and see if we can figure out what's disabling editing. :)
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!
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.
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.
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.
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!