I have a situation where i would want to give user ablity to add new row to the Grid but once the row is added to the grid, the user should only be able to modifiy/update a single column. Rest all the columns should remain read-only or disabled.
I tried almost everything using the AllowUpdate property of the grid and bands and also the CellActivation property for the columns but all in vein.
Please help me the same.
Hi,
Sorry, but I'm still not clear on what you are saying or what the problem is. I'm also not sure what these screen shots are intended to show.
What, exactly, is the problem? What is "not working?"
Maybe you could post a small sample project demonstrating the issue you are experiencing so I could take a look.
Hi Mike,
Maybe these screenshots will help:
First the screenshots and then the code. Note that the only thing I change is the CellActivation, no code changes, no other properties change.
This is the solution not working:
http://imageshack.us/a/img541/7508/tworkproduction.png
Here is a screenshot of the designer with the solution not working:
http://imageshack.us/a/img16/2715/tworkdesigner.png
Now, I just change the CellActivation property to "Allow Edit" and it starts working as expected:
http://imageshack.us/a/img855/8186/worksdesigner.png
And in action:
http://imageshack.us/a/img542/8790/worksproduction.png
And, here is the code:
Private Sub companiesGrid_InitializeRow(sender As Object, e As InitializeRowEventArgs) Handles companiesGrid.InitializeRow VerifyKeyFieldActivation(e.Row) End Sub
Private Sub VerifyKeyFieldActivation(row As UltraGridRow) If row.IsTemplateAddRow = False AndAlso row.IsAddRow = False Then row.Cells("CompanyName").Activation = Activation.Disabled Else row.Cells("CompanyName").Activation = Activation.AllowEdit End If End Sub
Hi Johnie,
I'm not following you. You are saying that you are setting the Activation property on the cell, but it still returns the old value? I don't see how that could possibly happen.
This solution worked for me, but I might add that if the column is set to NoEdit in the designer, the cell remains NoEdit after this code executes.
Thanks Mike, I pretty sure this will work in my case as well.