Hello.
I'm trying to toggle individual rows in my grid between editable and readonly. The columns in my grid have different values for the CellActivation property.
When a row is in the editable state its cells shall be able to be activated individually. But when in the readonly state the row shall be selected (and highlighted) instead of the cell the user clicked on.
Is there any chance I can achieve this kind of behavior?
Many thanks.
Hi Marcell,
I need a bit more info. How are you toggling the state of the row from editable to ReadOnly? What property settings are you using, exactly? And what settings are you using for CellActivation?
It sounds like what you need is the CellClickAction property, but this property doesn't apply on a row, it's on the Override so it applies to the whole band. There's no way to set it for a single row. So you will most likely have to write some code and handle the events of the grid to select the row when the user clicks on a cell in a non-editable row. I would try the CellClick or MouseDown events, but it's tough to say for sure without knowing exactly what settings you are using so I can try it out.
Hello Mike,thanks for your reply.
I use the Activation property of a row and set it to ActivateOnly in order to make it readonly. One of the columns of my grid (which contains only one band by the way) has CellActivation set to ActivateOnly and another column is set to NoEdit. The other ones are set to default value for CellActivation.
DisplayLayout.Override.SelectTypeRow of my grid is set to SelectType.Extended.
Yes, your're right: The CellClickAction is exactely what I'm looking for. But I need it on a per row basis. I had hoped that there would be a best-practice to overcome this limitation.
Yeah, unfortunately, CellClickAction doesn't apply to cells or rows, only columns, so there's no way to handle this with a property setting.
You might be able to use the MouseDown event to achieve something like this, but it's tricky, and it depends a lot on what behavior you need. Extended selection will also make things tougher, because I'm not sure what should happen if you click and drag across rows that have difference Activation settings.
Also, I'm a little puzzled by your choice of ActivateOnly here, though. If clicking to row will selecte the row, then why use ActivateOnly, which allows the user to edit a cell in the first place? I would think NoEdit would make more sense.
Does the user need to be able to select cells, as well as rows? If not, then using NoEdit would help a lot because clicking on a NoEdit cell will select that cell and you could then change that into a row selection in the BeforeSelectChange event, I think.